- iOS Programming Cookbook
- Hossam Ghareeb
- 167字
- 2021-07-09 18:29:49
Hiding navigation bar
- You can at any time hide or show the navigation bar based on any logic you have in your app by calling:
self.navigationController?.setNavigationBarHidden(true, animated: true)
Passing true to the preceding function hides the bar, and passing false will show the bar. Also, you can specify whether you want to do it with animation or not.
- UINavigationController has another awesome property called hidesBarsOnSwipe when you set it to true. The navigation bar will be hidden automatically when you swipe up a table view or a scroll view. Also, when you swipe down, it will be shown again. This feature is very nice, as it saves a lot of space for the user while scrolling a list of data to see as much data as possible on screen. Let's give it a shot; from our preceding example, open MasterViewController and add this line of code in the viewDidLoad function:
self.navigationController?.hidesBarsOnSwipe = true
- Then, build and run; you will note the bar hides or shows while scrolling:
推薦閱讀
- 阿里云數字新基建系列:云原生操作系統Kubernetes
- 曝光:Linux企業運維實戰
- Haskell Financial Data Modeling and Predictive Analytics
- Ubuntu Linux操作系統
- 異質結原理與器件
- Java EE 8 Design Patterns and Best Practices
- Ceph分布式存儲實戰
- Cassandra 3.x High Availability(Second Edition)
- 分布式系統設計實踐
- μC/OS-III內核實現與應用開發實戰指南:基于STM32
- 大學計算機應用基礎實踐教程(Windows 7+MS Office 2010)
- OpenStack Essentials(Second Edition)
- Java EE 8 High Performance
- Implementing Cloud Design Patterns for AWS(Second Edition)
- Linux深度攻略