Created
February 3, 2018 14:27
-
-
Save serhatsezer/6c53e558db0e8880e8594e5a8bf63b16 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 | |
| import Parchment | |
| class FirstVC: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| self.title = "First" | |
| self.view.backgroundColor = .red | |
| } | |
| } | |
| class SecondVC: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| self.title = "Second" | |
| self.view.backgroundColor = .blue | |
| } | |
| } | |
| class ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| let firstVC = FirstVC() | |
| firstVC.title = "asd" | |
| let secondVC = SecondVC() | |
| secondVC.title = "asd" | |
| let pagingViewController = FixedPagingViewController(viewControllers: [firstVC, secondVC]) | |
| pagingViewController.menuItemSize = .sizeToFit(minWidth: 120, height: 50) // I had to gave a menuItemSize value if I didn't menuItem would be collapsed. | |
| addChildViewController(pagingViewController) | |
| view.addSubview(pagingViewController.view) | |
| pagingViewController.didMove(toParentViewController: self) | |
| pagingViewController.view.translatesAutoresizingMaskIntoConstraints = false | |
| NSLayoutConstraint.activate([ | |
| pagingViewController.view.topAnchor.constraint(equalTo: view.topAnchor), | |
| pagingViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), | |
| pagingViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), | |
| pagingViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), | |
| ]) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment