iphone - iOS 7 导航栏文本和箭头颜色

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

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

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

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

最佳答案

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


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

  1. iOS 7 UI Transition Guide .
  2. How to Update Your App for iOS 7 .

Apple 文档 for barTintColor说:

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;

https://stackoverflow.com/questions/19029833/

相关文章:

ios - 在一个 UITableViewCell 上隐藏分隔线

objective-c - 了解 dispatch_async

ios - 如何在 iOS 上获取设备品牌和型号?

ios - 不区分大小写的比较 NSString

ios - 如何在 iOS 上进行 base64 编码?

ios - 使 UINavigationBar 透明

ios - 将 NSString 转换为 NSDate(然后再返回)

ios - 架构 i386 : _OBJC_CLASS_$_SKPSMTPMessage", 的 u

iphone - 如何在我的 iPhone 应用程序中使用 NSError?

objective-c - iOS 8 对尚未渲染的 View 进行快照会导致快照为空