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

2019-05-30  本文已影响0人  FM_0138

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

}

上一篇下一篇

猜你喜欢

热点阅读