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

查看:115
本文介绍了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用户界面转换指南

  2. 如何更新iOS 7应用程序

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





$ b Apple文档 apple_ref / occ / instp / UINavigationBar / barTintColor> barTintColor 说:


Apple Documentation for barTintColor says :


默认情况下,此颜色为半透明,除非您设置
半透明属性为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天全站免登陆