iOS 7 导航栏文本和箭头颜色 [英] iOS 7 Navigation Bar text and arrow color

查看:20
本文介绍了iOS 7 导航栏文本和箭头颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将导航栏的背景设置为黑色,并将其中的所有颜色设置为白色.

I want to set background for Navigation Bar to be black and all colors inside it to be white.

所以,我使用了这个代码:

So, I used this code :

[[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]];

但是后退按钮文字颜色箭头条形按钮仍然是默认的蓝色.
如何更改如下图所示的颜色?

But back button text color, arrow and bar button have still default blue color.
How to change those colors like on image below?

推荐答案

UINavigationBar 的某些属性的行为已从 iOS 7 更改.您可以在下图中看到:

Behavior from some of the properties of UINavigationBar has changed from iOS 7. You can see in the image shown below :

我想与您分享两个漂亮的链接.有关更多详细信息,您可以访问这些链接:

Two beautiful links I'd like to share with you. For more details you can go through these links :

  1. iOS 7 UI 转换指南.
  2. 如何更新适用于 iOS 7 的应用.

<小时>

Apple 文档,用于 barTintColor 说:

默认情况下这种颜色是半透明的,除非你设置半透明属性为NO.

This color is made translucent by default unless you set the translucent property to NO.

示例代码:

self.navigationController.navigationBar.barTintColor = [UIColor blackColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
[self.navigationController.navigationBar 
 setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
self.navigationController.navigationBar.translucent = NO;

这篇关于iOS 7 导航栏文本和箭头颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆