Skip to content

Instantly share code, notes, and snippets.

@riteshhgupta
Created March 22, 2019 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riteshhgupta/7d1459757d985dbc08fb298fadcba9be to your computer and use it in GitHub Desktop.
Save riteshhgupta/7d1459757d985dbc08fb298fadcba9be to your computer and use it in GitHub Desktop.
import UIKit
class FeedViewController: UIViewController {
lazy var navigationBarController: NavigationBarController = {
NavigationBarController()
}()
override var navigationItem: UINavigationItem {
return navigationBarController.navigationItem
}
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
add(child: navigationBarController)
}
}
extension FeedViewController {
class NavigationBarController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .clear
title = "Feed"
navigationItem.searchController = UISearchController(searchResultsController: nil)
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: nil, action: nil)
navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .camera, target: nil, action: nil)
}
}
}
extension UIViewController {
func add(child: UIViewController) {
addChild(child)
child.didMove(toParent: self)
view.addSubview(child.view)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment