美文网首页
iOS隐藏导航栏

iOS隐藏导航栏

作者: 钦川 | 来源:发表于2018-04-26 15:13 被阅读19次

    我的实践

    1.在BaseViewController中,当viewWillAppear时,根据情况显示或隐藏导航栏
    BaseViewController.h

    #import "QqcBaseViewController.h"
    
    @interface BaseViewController : QqcBaseViewController
    
    #pragma mark - polymorphy
    //是否需要显示导航栏
    - (BOOL)isHideNavigationbar;
    
    @end
    

    BaseViewController.m

    #import "BaseViewController.h"
    
    @implementation BaseViewController
    
    #pragma mark - polymorphy
    //是否需要显示导航栏
    - (BOOL)isHideNavigationbar {
        return NO;
    }
    
    #pragma mark - system framework
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        //是否显示导航栏
        BOOL isHideNavi = [self isHideNavigationbar];
        [self.navigationController setNavigationBarHidden:isHideNavi animated:YES];
    }
    
    @end
    

    2.在SomeoneViewController中, 定制是否隐藏导航栏

    - (BOOL)isHideNavigationbar {
        return YES;
    }
    

    相关文章

      网友评论

          本文标题:iOS隐藏导航栏

          本文链接:https://www.haomeiwen.com/subject/sjzplftx.html