Change color of UINavigationBar

不问归期 提交于 2019-12-02 17:23:07

问题


Hello,

I created UINavigationBar, and I try to change the color bar to aqua color (As in Nib file)

How do I do it?


回答1:


[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:0 green:.62 blue:.984 alpha:1]];

Dude, try this to get [UIColor Aqua] throughout your app.




回答2:


You can set either tintColor or backgroundImage to your UINavigationBar

- (void) viewDidLoad
{
   //set background image
   [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"background.png"]];

  //OR set background Color
  [self.navigationController.navigationBar setTintColor:[UIColor blueColor]];
}

I'm not sure but if you'll put this in first call method of your app it may apply everywhere!

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { }



回答3:


try this,

UINavigationController *navigationController;
UIColor* aqua = [UIColor colorWithRed:0 green:1 blue:1 alpha:1];
navigationController.navigationBar.tintColor = [UIColor aqua];

regards




回答4:


UINavigationBar *bar = [self.navigationController navigationBar];
[bar setTintColor:[UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0]];

Please try above code for set color.

Edited

 UINavigationBar *bar = [self.navigationController navigationBar];
UIColor* aqua = [UIColor colorWithRed:0 green:1 blue:1 alpha:1];
[bar setTintColor:aqua];

This Code use for the aqua color




回答5:


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

Call this function befor the ViewController will appear, e.g. in viewDidLoad:



来源:https://stackoverflow.com/questions/12691876/change-color-of-uinavigationbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!