简体   繁体   中英

how to make navigation bar always appear on top and not scroll with content IOS 8

I want to show navigation bar always visible on top while scrolling view . Kindly share code or sample if integrated. I want similar to facebook app navigation bar.

At first you need to have navigation controller (Editor -> embed in -> Navigation Controller) while your view controller is selected. Then use Show(egPush) or Show Detail as a storyboard segue kind. Navigation bar will automatically appear.

This code hides bar:

self.navigationController?.navigationBarHidden = true

This shows bar:

self.navigationController?.navigationBarHidden = true

This code hides bar on swipe (like facebook app)

 self.navigationController?.hidesBarsOnSwipe = true 

This should keep bar visible

 self.navigationController?.hidesBarsOnSwipe = true 

When you set navigation controller, navigation bar will be always at the top as fixed. Your container starts from below the navigation bar.

self.navigationController.navigationBarHidden = false

In fact you don't even have to write this code, because default functionality of navigation bar is visible always.

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