美文网首页
ios 更改单个页面导航栏的颜色

ios 更改单个页面导航栏的颜色

作者: FM_0138 | 来源:发表于2019-05-30 09:44 被阅读0次

如果只改单个页面导航栏颜色,则在viewWillAppear:   viewWillDisappear: 方法中添加如下内容

QP_Color_Background_Nav_Call   新页面的导航栏颜色

QP_Color_Background_Nav  其他页面的导航栏颜色

QP_Color_Text_Nav_title  导航栏标题颜色

- (void)viewWillAppear:(BOOL)animated{

    [superviewWillAppear:animated];

    self.navigationController.navigationBar.barTintColor = QP_Color_Background_Nav_Call;

    self.navigationController.navigationBar.tintColor = QP_Color_Background_White;

    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];

    titleLabel.font = [UIFont boldSystemFontOfSize:18];

    titleLabel.textColor = QP_Color_Background_White;

    titleLabel.textAlignment = NSTextAlignmentCenter;

    titleLabel.text=self.title;

    self.navigationItem.titleView = titleLabel;

}

- (void)viewWillDisappear:(BOOL)animated{

    [superviewWillDisappear:animated];

    self.navigationController.navigationBar.barTintColor = QP_Color_Background_Nav;

    self.navigationController.navigationBar.tintColor = QP_Color_Text_Nav_title;

}

相关文章

网友评论

      本文标题:ios 更改单个页面导航栏的颜色

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