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

如果只改单个页面导航栏颜色,则在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;

扫描二维码关注公众号,回复: 6451366 查看本文章

    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;

}

猜你喜欢

转载自blog.csdn.net/weixin_34375251/article/details/90968153
今日推荐