rickytan / RTRootNavigationController

Implicitly make every view controller has its own navigation bar
MIT License
2.15k stars 379 forks source link

设置 tintColor 没有效果 #205

Closed LZS-bobo closed 6 years ago

LZS-bobo commented 6 years ago

继承 RTRootNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.useSystemBackBarButtonItem = NO;

    [self.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]] forBarMetrics:UIBarMetricsDefault];
    self.navigationBar.tintColor = TITLE_TEXT_COLOR;
}

- (void)back
{
    [self popViewControllerAnimated:YES];
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    viewController.navigationController.navigationBar.tintColor = TITLE_TEXT_COLOR;
    //非跟控制器
    if (self.childViewControllers.count) {

        self.tabBarController.tabBar.hidden = YES;
        //隐藏底部导航条
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_back"] style:UIBarButtonItemStyleDone target:self action:@selector(back)];
        viewController.rt_disableInteractivePop = NO;
        viewController.hidesBottomBarWhenPushed = YES;

    }
    [super pushViewController:viewController animated:animated];
}
rickytan commented 6 years ago

改文字颜色?还是图片颜色?

LZS-bobo commented 6 years ago

文字和图片都没有效果

rickytan commented 6 years ago

首先,你这个需求感觉完全没必要继承重写;然后改标题文字颜色用 titleAttributes,

self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: xxx};

改图片颜色,图片要改为 Template,而不是 Defaultimage