美文网首页
修改Navigation Bar上的返回按钮文本颜色,箭头颜色以

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

作者: ShineYangGod | 来源:发表于2017-01-05 11:32 被阅读187次

我想设置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;

相关文章

网友评论

      本文标题:修改Navigation Bar上的返回按钮文本颜色,箭头颜色以

      本文链接:https://www.haomeiwen.com/subject/qeqzvttx.html