修改Navigation Bar上的返回按钮文本颜色,箭头颜色以及导航栏按钮的颜色

我想设置Navigation Bar的背景颜色为黑色,然后所有内部颜色为白色.
因此,我用了这段代码:

[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:   [UIColor whiteColor],NSForegroundColorAttributeName,[UIColor whiteColor],NSForegroundColorAttributeName,[NSValue valueWithUIOffset:UIOffsetMake(0, -1)],NSForegroundColorAttributeName,[UIFont fontWithName:@
"Arial-Bold"
 size:0.0],NSFontAttributeName,nil]
];

但是,返回按钮文本颜色,箭头颜色以及导航栏按钮的颜色仍然为默认颜色,怎么修改它们?

解决方法 1:

自从IOS7后UINavigationBar的一些属性的行为发生了变化.你可以在下图看到:


enter image description here

现在,如果你要修改它们的颜色,用下面的代码:

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

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];

self.navigationController.navigationBar.translucent = NO;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容