【发布时间】:2014-08-03 01:15:42
【问题描述】:
我遇到了一个非常奇怪的问题,让我发疯。
问题是有时(并不总是发生),在显示一个弹出窗口后,条形按钮和任何 UISegmentedControl 会变成红色,而它们应该是白色的(见下图)。
这也是我设置应用程序色调颜色的代码(在应用程序委托初始化方法中):
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor redColor], NSForegroundColorAttributeName,
shadow,NSShadowAttributeName,
[UIFont fontWithName:@"HelveticaNeue-Thin" size:18],
NSFontAttributeName,
nil]];
[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor redColor], NSForegroundColorAttributeName,
shadow,NSShadowAttributeName,
[UIFont fontWithName:@"HelveticaNeue-Thin" size:18],
NSFontAttributeName,
nil] forState:UIControlStateNormal];
if ([self.window respondsToSelector:@selector(setTintColor:)])
self.window.tintColor = [UIColor redColor];
[[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor darkGrayColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
知道为什么会这样吗?我认为如果我的代码有问题,导航栏按钮和分段控件会在应用程序启动后变为红色,而不是在一段时间后。大家觉得呢?
谢谢
【问题讨论】:
标签: ios7 uinavigationbar uibarbuttonitem uisegmentedcontrol tintcolor