Created
April 12, 2018 22:45
-
-
Save uruly/bcea8bdb066ed6e003dbbf7c0becdf41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| self.view.backgroundColor = UIColor.blue | |
| //ボタンタップでSwipeNavigationViewControllerに遷移する | |
| let btn = UIButton(frame:CGRect(x:10,y:30,width:100,height:50)) | |
| btn.addTarget(self, action: #selector(self.btnTapped), for: .touchUpInside) | |
| btn.backgroundColor = UIColor.red | |
| self.view.addSubview(btn) | |
| } | |
| @objc func btnTapped() { | |
| let pageController:UIPageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) | |
| let navigationController:SwipeNavigationViewController = SwipeNavigationViewController(rootViewController: pageController) | |
| //これがないと上に隙間ができる | |
| pageController.automaticallyAdjustsScrollViewInsets = false | |
| let firstView = FirstViewController() | |
| let secondView = SecondViewController() | |
| navigationController.viewControllerArray = [firstView,secondView] | |
| present(navigationController, animated: true, completion: nil) | |
| } | |
| override func didReceiveMemoryWarning() { | |
| super.didReceiveMemoryWarning() | |
| // Dispose of any resources that can be recreated. | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment