简体   繁体   中英

Disable navigation bar transparency while pushViewController

I have TableViewController embed in NavigationController, also I have DetailedViewController that should be opened when cell on in TableViewController is selected.

So I calling

navigationController?.pushViewController(DetailedViewController, animated: true)

My navigation bar settings:

navigationController?.navigationBar.isTranslucent = false
navigationController?.navigationBar.barTintColor = .green

DetailedViewController's navigation bar is hidden

self.navigationController?.isNavigationBarHidden = true

and while I see push animation from TableViewController to DetailedViewController I can see some of content from Controller that stands behind TableViewController though navigation bar that becomes transparent for this transition.

What can I do with it?

This is compilers undefined behaviour, You can achieve your goal with the following operations.

1) Select Navigation controller-> Navigation Bar. 2) Untick the translucent property. (See editor pane). 3) Also hide the the navigation Bar from storyboard. 4) Show the navigation bar in view controller where it is required.

//Code to show navigation bar:

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    self.navigationController?.navigationBar.isHidden = false
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(true)
    self.navigationController?.navigationBar.isHidden = true
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM