设置导航栏的色调颜色恢复为iOS 6蓝色 [英] setting tint color for navigation bars reverts back to iOS 6 blue color

查看:163
本文介绍了设置导航栏的色调颜色恢复为iOS 6蓝色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iOS 6应用程序,该应用程序使用以下命令将所有导航栏按钮的色调设置为绿色:

[[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:(100.0f/255.0f) green:(190.0f/255.0f) blue:(100.0f/255.0f) alpha:1.0f]];

这是在应用程序启动时完成的.这在运行iOS 6的手机上可以正常工作,但在运行iOS 7的手机上,有时会出现色调颜色,有时则不会.当显示AlertView时尤其如此.这样会擦除显示正确绿色色调的所有按钮的色调颜色,并将按钮还原为标准的iOS 6蓝色色调.

为确认这不是我在较大项目中正在做的事情,我创建了一个基本模板Master-detail xcode项目进行确认,仅添加了上述行和alertview弹出窗口,并且在此也发生了. /p>

我想知道是否1.)其他任何人都在经历2.)如果是这样,您是否找到了解决方法,并且3.)任何人都知道Apple是否已将其确认为错误.

目前,我们不打算将此应用转换为iOS 7外观,因此这不是一种选择.谢谢.

解决方案

Apple官方文档中的

在iOS 6中,tintColor为导航栏,标签的背景着色 条,工具栏,搜索条和范围条.着色酒吧背景 在iOS 7中,请改用barTintColor属性.

您应该参考完整的UI转换指南,以了解哪些UI元素在iOS 7中的行为有所不同.如果要同时支持这两个元素,则可以检查iOS版本并为每个版本放置不同的代码:

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
   // Load resources for iOS 6.1 or earlier
} else {
   // Load resources for iOS 7 or later
}

I have an iOS 6 application that sets the tint color for all navigation bar buttons to a green color by using the following:

[[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:(100.0f/255.0f) green:(190.0f/255.0f) blue:(100.0f/255.0f) alpha:1.0f]];

This is done at the launch of the application. This works fine on phones running iOS 6 but on phones running iOS 7 the tint color is sometimes there and and sometimes not. It especially happens when an AlertView is displayed. This wipes out the tint color of any buttons displaying the correct green tint and reverts the buttons back to the standard iOS 6 blue tint.

To confirm it isn't something I'm doing in my larger project, I have created a basic template Master-detail xcode project to confirm and only added the above line and an alertview popup and this happens there as well.

I am wondering if 1.) anyone else is experiencing this 2.) if so, have you found a work-around and 3.) anyone know if Apple has confirmed this as a bug.

At this time we are not looking to convert this app to the iOS 7 look-and-feel so that is not an option. Thx.

解决方案

From the official Apple Documentation:

In iOS 6, tintColor tinted the background of navigation bars, tab bars, toolbars, search bars, and scope bars. To tint a bar background in iOS 7, use the barTintColor property instead.

You should refer to the complete UI transition guide to see what UI elements behave in a different way in iOS 7. If you want to support both you can check the iOS version and put different code for each version:

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
   // Load resources for iOS 6.1 or earlier
} else {
   // Load resources for iOS 7 or later
}

这篇关于设置导航栏的色调颜色恢复为iOS 6蓝色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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