繁体   English   中英

尝试更改导航栏背景颜色,但失败

[英]try to change navigationbar background color but failed

我使用下面的代码更改了导航栏的背景颜色

- (void)viewDidLoad
{

    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithHexString:@"6cd3c5"]];

    [super viewDidLoad];

}

酒吧背景颜色不会立即改变,我必须pushViewController:someViewController

然后返回,颜色可能会改变。

欢迎您发表评论

尝试这个:

[self.navigationController.navigationBar setBarTintColor:[UIColor colorWithHexString:@"6cd3c5"]];
[self.navigationController.navigationBar setTranslucent:NO];

阅读此内容以获得更多说明。

appearance用于将来的外观。 如果要显示外观,请在加载视图之前使用。

否则使用

    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithHexString:@"6cd3c5"]];

暂无
暂无

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

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