iOS 7条按钮项:自定义背景图像和高亮状态使图像变暗
我的iOS应用程序有一个自定义主题,在iOS 6上,它看起来就像我想要的一样。 但在iOS 7上,操作系统会自动将背景(以及我用作按钮的图像)本身变暗,因此看起来有所不同 因此,我有一个带有自定义图像和以下代码的条形按钮项:iOS 7条按钮项:自定义背景图像和高亮状态使图像变暗,ios,ios7,Ios,Ios7,我的iOS应用程序有一个自定义主题,在iOS 6上,它看起来就像我想要的一样。 但在iOS 7上,操作系统会自动将背景(以及我用作按钮的图像)本身变暗,因此看起来有所不同 因此,我有一个带有自定义图像和以下代码的条形按钮项: UIImage *navbarButton = [[UIImage imageNamed:@"navbar_button"] resizableImageWithCapInsets:UIEdgeInsetsMake(1, 1
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];
我做错了什么/忘记了什么?试着做[[UINavigationBar外观]setTintColor:[UIColor whiteColor]]。我有一个类似的问题,这使它变得轻松起来 尝试执行[[UINavigationBar外观]setTintColor:[UIColor whiteColor]]。我有一个类似的问题,这使它变得轻松起来 不,这只会更改条形图项目上的图标(我已经有了一个
self.window.tintColor=[UIColor whiteColor];
)哦,我是说bakcgroundcolor。抱歉,我记不清了,因为我现在无法访问我的文件,我只在导航栏上看到barTintColor
和tintColor
,这两个都不起作用。不,这只会更改栏项上的图标(我已经有了self.window.tintColor=[UIColor whiteColor];
)哦,我是说bakcgroundcolor。对不起,我记不清了,因为我现在无法访问我的文件,我只在导航栏上看到barTintColor
和tintColor
,这两个功能都不起作用。
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];
}