Presenting UIViewController from UITabBarViewController~>RootViewController.
let uploadViewController = UIStoryboard.identifier(.Home).instantiateViewController(identifier: "UploadViewController") as! UploadViewController
let navigationController = UINavigationController(rootViewController: uploadViewController)
navigationController.modalPresentationStyle = .overFullScreen
navigationController.statusBar(colour: .ThemeColor)
self.present(navigationController, animated: false, completion: nil)
//UploadViewcontroller
override func viewDidLoad() {
super.viewDidLoad()
self.addCrossAction()
setTitle(text: "Upload")
// Do any additional setup after loading the view.
}
func addCrossAction(){
navigationController?.navigationBar.backgroundColor = .ThemeColor
navigationController?.isNavigationBarHidden = false
navigationController?.navigationBar.hide_NavigationBar_BottonLine()
let button = UIButton(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
button.setImage(UIImage(named: "crossButtonWhite"), for: .normal)
button.addTarget(self, action: #selector(crossButtonClicked), for: .touchUpInside)
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: button)
}
Observer that the NavigationBar Not completed displayed..
Please find below Image.
How to have complete blue.ThemeColor NavigationBar.
instead of:
navigationController?.navigationBar.backgroundColor = .ThemeColor
try:
UINavigationBar.appearance().barTintColor = .ThemeColor
or (iOS >13):
UINavigationBarAppearance().backgroundColor = .ThemeColor
if you want total blue bar with large title
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.largeTitleDisplayMode = .always
otherwise set a dummy view with ThemeColor background on top of your table view and anchor the table to dummy view bottom, before assign to your navbar bg color to clear.
Declare your dummyView:
let dummyView = UIView()
in viewDidLoad:
dummyView.backgroundColor = .ThemeColor
dummyView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(dummyView)
dummyView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
dummyView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
dummyView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
dummyView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
after that assign tableView top constraints to dummyView bottom constraints... if You search an extension to set your navBar programmatically, take a look to my https://stackoverflow.com/a/58361273/5575955
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.