开发者

UITableViewController tintColor

开发者 https://www.devze.com 2023-02-01 15:44 出处:网络
I am trying to setTintColor for a viewcontroller that inherits from a UITableViewController. I tried to put

I am trying to setTintColor for a viewcontroller that inherits from a UITableViewController.

I tried to put

[self.navigationController.navigationBar setTintColor:[UIColor blackColor]];

as the last line in loadView, but the color doesn't change. Where should I make this change?

Here is the interface definition of the controller:

@interface MyViewController : UITableViewController 
{
    Model *model;

    NSArray * calculators;
}
@end
开发者_开发问答

UPDATE: I finally put it in viewDidAppear and it worked.


Are you sure that your self.navigationController is not nil? This is a usual bug happenning all the time that you didn't present your MyViewController with a navigationController


Try this

self.navigationController.navigationBar.tintColor = [UIColor blackColor];


I put my solution in the question.


-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setTintColor:[UIColor blackColor]];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号