[ios] 首页隐藏navigation bar
程序员文章站
2022-06-10 22:17:51
...
How to hide a navigation bar from first ViewController in Swift?
refer to :
http://*.com/questions/29209453/how-to-hide-a-navigation-bar-from-first-viewcontroller-in-swift
override func viewWillAppear(_ animated: Bool) { super.viewWillAappear(animated) // Hide the navigation bar on the this view controller self.navigationController?.setNavigationBarHidden(true, animated: true) } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) // Show the navigation bar on other view controllers self.navigationController?.setNavigationBarHidden(false, animated: true) }
原理:因为setNavigationBarHidden设置是全局的,所有页面都会响应。所以通过页面出现时消失,到其他页时显示来实现。
object-c method:
-(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; self.navigationController.navigationBarHidden = YES; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; self.navigationController.navigationBarHidden = NO; }
上一篇: List集合的理解
下一篇: 埃及古城惊现:3500年前动物残骸