Change UINavigationItem colour

前端 未结 3 1406
清酒与你
清酒与你 2021-01-05 23:27

I need to set custom colors to my UINavigationBar buttons. I\'m doing the following thing(RGB func is a define):

- (void)viewWillAppear:(BOOL)animated
{

for         


        
3条回答
  •  北海茫月
    2021-01-05 23:57

    For IOS5 will have to use "setBackgroundImage:forBarMetrics:"

    try this code to apply all UINavigationItem / UINavigationBar

     if([[UINavigationBar class] respondsToSelector:@selector(appearance)]){ //iOS >=5.0
        //use for UINavigationBar Custom image.
        [[UINavigationBar appearance] setBackgroundImage:[UIImage imageWithNamed:@"navImage.png"] forBarMetrics:UIBarMetricsDefault];
    
        //use for UINavigationItem custom color
        [[UINavigationBar appearance] setTintColor:[UIColor greenColor]];
    }
    

提交回复
热议问题