这个问题与运行iOS 7的Xcode 5有关,并且非常奇怪。我试图将所有UInavigation和UIBarButtonItem的文本颜色设置为白色。
因此,在我的应用程序启动代理中,我设置了以下代码。
如果我两次启动“发送邮件”操作 - 第一次,我看到UIBarButton项是白色的。然后我看了一下并点击了取消按钮 - 第二次,我看到它们都变成灰色且仅有标题可见。 - 这在我的iPhone模拟器和运行iOS 7的iPhone中都会发生。
如何解决这个问题?
因此,在我的应用程序启动代理中,我设置了以下代码。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIImage *NavigationPortraitBackground = [UIImage imageNamed:@"button_header_blue"];
// Set the background image all UINavigationBars
[[UINavigationBar appearance] setBackgroundImage:NavigationPortraitBackground forBarMetrics:UIBarMetricsDefault];
// Set the text appearance for navbar
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIColor whiteColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 0)], UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"Helvetica Neue" size:21], UITextAttributeFont,
nil]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor],
UITextAttributeTextColor,
[UIColor whiteColor],
UITextAttributeTextShadowColor,
nil];
[[UIBarButtonItem appearance] setTitleTextAttributes:attributes forState: UIControlStateNormal];
[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];
// Override point for customization after application launch.
return YES;
}
如果我两次启动“发送邮件”操作 - 第一次,我看到UIBarButton项是白色的。然后我看了一下并点击了取消按钮 - 第二次,我看到它们都变成灰色且仅有标题可见。 - 这在我的iPhone模拟器和运行iOS 7的iPhone中都会发生。
如何解决这个问题?
![enter image description here](https://istack.dev59.com/Wtr1Q.webp)
![enter image description here](https://istack.dev59.com/btmWM.webp)