ios change the color of a single page navigation bar

If only a single page navigation bar color change, then viewWillAppear: add the following methods: viewWillDisappear

Navigation bar color QP_Color_Background_Nav_Call new page

Navigation bar color QP_Color_Background_Nav other pages

QP_Color_Text_Nav_title Navigation Bar title color

- (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;

}

Guess you like

Origin blog.csdn.net/weixin_34375251/article/details/90968153