简体   繁体   English

更改标签栏控制器的导航栏背景色

[英]change the navigationbar backgroundcolor for a tabbarcontroller

My UI is just from TabBarController A to TabBarController B, those two TabBarController with different child items. 我的UI只是从TabBarController A到TabBarController B,这两个具有不同子项的TabBarController。 Now I want to change the TabBarController B's navigationbar backgroundColor, but any of those methods followed are not work. 现在,我想更改TabBarController B的导航栏backgroundColor,但是遵循的任何这些方法均无效。

tabBarViewControllerA.navigationController.navigationBar.backgroundColor = [UIColor yellowColor]; tabBarViewControllerA.navigationController.navigationBar.backgroundColor = [UIColor yellowColor]; babBarViewControllerB.navigationController.navigationBar.backgroundColor = [UIColor yellowColor]; babBarViewControllerB.navigationController.navigationBar.backgroundColor = [UIColor yellowColor]; babBarViewControllerB.childViewControllers.firstObject.navigationController.navigationBar.backgroundColor = [UIColor yellowColor]; babBarViewControllerB.childViewControllers.firstObject.navigationController.navigationBar.backgroundColor = [UIColor yellowColor];

Also, from the debug->view debugging->capture view hierarchy, I can see the navigationbar backgroundcolor has changed, but the finial color is not changes. 另外,从debug-> view debugging-> capture视图层次结构中,我可以看到导航栏的backgroundcolor已更改,但最终颜色未更改。 Please give me some ideas about the problem. 请给我一些关于这个问题的想法。

发现只需要更改navigationbar.bartintcolor

试试这个。

 self.navigationController.navigationBar.barTintColor = [UIColor orangeColor];

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

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