简体   繁体   English

更改导航控制器底部工具栏的颜色

[英]Changing the colour of Navigation Controller bottom toolBar

I am trying to change the colour of the bottom bar of my Navigation Controller. 我正在尝试更改导航控制器底部栏的颜色。 I have managed to change the top NavBar in my appdelegate by adding 我设法通过添加以下内容来更改appdelegate中顶部的NavBar

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.688 green:0.437 blue:0.794 alpha:1.0]];

I want to apply this to the bottom bar also. 我也想将其应用于底部栏。

You can use [UIToolbar appearance] to set the appearance of UIToolbar 您可以使用[UIToolbar appearance]设置UIToolbar的外观

Good luck 祝好运

I had the same problem, but could escape this by setting a tag for my navigationBar in my storyboard. 我遇到了同样的问题,但是可以通过在情节提要中为我的navigationBar设置标签来避免此问题。 Then I could change the navigationBar's color like this: 然后,我可以像这样更改navigationBar的颜色:

let navigationBar = (self.view.viewWithTag(someNumber) as UINavigationBar) navigationBar.barTintColor = UIColor.blackColor() 让navigationBar =(self.view.viewWithTag(someNumber)as UINavigationBar)navigationBar.barTintColor = UIColor.blackColor()

This is not ideal unless you can guarantee that the number of subviews in your view is less than "someNumber". 除非您可以保证视图中的子视图数量少于“ someNumber”,否则这是不理想的。 If you can though, then this should work. 如果可以,那么应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM