iOS 优雅地隐藏导航栏NavigationBar (Objc)

 

 

 

@interface FSViewController () <UINavigationControllerDelegate>

@end

@implementation FSViewController

#pragma mark - lifeCycle
- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 设置导航控制器的代理为self
    self.navigationController.delegate = self;
}


// 将要显示控制器
#pragma mark - UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 判断要显示的控制器是否是自己
    BOOL isSelf = [viewController isKindOfClass:[self class]];
    [self.navigationController setNavigationBarHidden:isSelf animated:YES];
}

 

 

注意:

不推荐使用点访问方式来设置导航栏的显示/隐藏,因为如果在设置导航栏隐藏的同时有动画在进行,

导航栏的位置就会出现黑色块,这样做是极其影响用户体验的!

 

 

参考资料:http://blog.csdn.net/ws1352864983/article/details/51932388

 

 


 转载请注明出处:http://www.cnblogs.com/ficow/p/7141984.html

posted @ 2017-07-09 16:53  Ficow  阅读(6738)  评论(0编辑  收藏  举报