Set NavigationBar Tint Color in iOS 7

大兔子大兔子 提交于 2020-01-03 02:31:12

问题


Am trying to set the tint for all navigation bars from my appdelegate in iOS 7. This worked always before, but for some reason now, nothing is changing. In the didFinishLaunching part of my appDelegate I have:

[[UINavigationBar appearance] setTintColor:toolbarcolor];

However, the bar stays the default translucent option.


回答1:


You can set the bar tint color using the barTintColor property:

[[UINavigationBar appearance] setBarTintColor:[UIColor purpleColor]];

If you also don't want the navigation bar to be translucent, you can set the translucent property to NO.

Unfortunately, the translucent property is not available on the UINavigationBar appearance proxy, so you will have to set this property individually (in your storyboard, .xib, or in something like viewDidLoad in your controller).




回答2:


Swift version:

    UINavigationBar.appearance().barTintColor = colorBar



回答3:


If you want to set bar tint color for whole application, write in "didFinishLaunchingWithOptions" method of AppDelegate.m

[[UINavigationBar appearance] setBarTintColor:[UIColor orangeColor]];

Following is output :




回答4:


In Swift 3.0

 let navigationBarAppearnce = UINavigationBar.appearance()

A navigation bar’s tintColor affects the color of the back indicator image, button titles, and button images:

navigationBarAppearnce.tintColor = UIColor.white

The barTintColor property affects the color of the bar itself:

navigationBarAppearnce.barTintColor = UIColor(red: 0.180, green: 0.459, blue: 0.733, alpha: 1.00)



来源:https://stackoverflow.com/questions/19521254/set-navigationbar-tint-color-in-ios-7

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