我的iOS应用程序有一个自定义主题,在iOS 6上它看起来像我想要的那样。但是在iOS 7上,操作系统会自动使背景(以及我用作按钮的图像)本身变暗,因此看起来不同。
所以我有一个带有自定义图像和以下代码的栏按钮项:
UIImage *navbarButton = [[UIImage imageNamed:@"navbar_button"]
resizableImageWithCapInsets:UIEdgeInsetsMake(1, 1, 1, 1)];
UIImage *navbarButtonHighlight = [[UIImage imageNamed:@"navbar_button_highlight"]
resizableImageWithCapInsets:UIEdgeInsetsMake(1, 1, 1, 1)];
[[UIBarButtonItem appearance] setBackgroundImage:navbarButton
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackgroundImage:navbarButtonHighlight
forState:UIControlStateHighlighted
barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackgroundImage:navbarButtonHighlight
forState:UIControlStateSelected
barMetrics:UIBarMetricsDefault];
我做错了什么/忘记了什么?
if([Utilities iOSVersion] >= 7){
[self.navigationController.navigationBar setBarTintColor:[UIColor whateverColorYouWant]];
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
//translucent is key
self.navigationController.navigationBar.translucent = NO;
}
/**
* @return this device OS version
*/
+(int)iOSVersion{
NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
return [[ver objectAtIndex:0]intValue];
}
尝试执行 [[UINavigationBar 外观] setTintColor:[UIColor whiteColor]]。我有一个类似的问题,这减轻了它。