Ios7 iOS 7:显示弹出窗口后,着色颜色会随机变化
我遇到了一个非常奇怪的问题,这让我发疯 问题是,有时它并不总是发生,在显示弹出窗口后,条形按钮和任何UISegmentedControl都会变成红色,而它们应该是白色的。请参见下图 下面是应用程序委托初始化方法中的代码,我使用该方法设置应用程序的着色颜色:Ios7 iOS 7:显示弹出窗口后,着色颜色会随机变化,ios7,uinavigationbar,uibarbuttonitem,uisegmentedcontrol,tintcolor,Ios7,Uinavigationbar,Uibarbuttonitem,Uisegmentedcontrol,Tintcolor,我遇到了一个非常奇怪的问题,这让我发疯 问题是,有时它并不总是发生,在显示弹出窗口后,条形按钮和任何UISegmentedControl都会变成红色,而它们应该是白色的。请参见下图 下面是应用程序委托初始化方法中的代码,我使用该方法设置应用程序的着色颜色: [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
[[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];
你知道为什么会这样吗?我认为,如果我的代码有问题,导航栏按钮和分段控件将在应用程序启动后变为红色,而不是在一段时间后。你们觉得怎么样
谢谢
介意尝试将背景色设置为白色吗?似乎正是这种情况发生了变化。如果这纠正了它,那么我们就有了一个起点
[[UITabBar appearance] setBackgroundColor:[UIColor whiteColor];
试着回答 在评论了以下两行之后,问题就消失了:
if ([self.window respondsToSelector:@selector(setTintColor:)])
self.window.tintColor = [UIColor redColor];
嗨,普拉舍,谢谢你的回答。我试试看。顺便说一句,我不明白的是,为什么在显示弹出窗口后一段时间会发生这种情况,而不是在应用程序开始运行后发生。有人知道吗?