IOS 7按钮图像颜色
我的IOS 7按钮图像颜色,ios,objective-c,ios7,uibutton,uiimage,Ios,Objective C,Ios7,Uibutton,Uiimage,我的ui按钮的一部分是ui图像,IOS 7将其颜色从黑色更改为蓝色。我尝试了这里提供的解决方案:将按钮类型更改为uibuttonypesystem,但这没有帮助,图像仍然是蓝色的。以下是我使用的通用代码: UIButton *iWantPlan = [UIButton buttonWithType:UIButtonTypeSystem]; iWantPlan.frame = CGRectMake(self.view.bounds.size.width/2-bgImageWidth/2, plan
ui按钮
的一部分是ui图像
,IOS 7将其颜色从黑色更改为蓝色。我尝试了这里提供的解决方案:将按钮类型更改为uibuttonypesystem
,但这没有帮助,图像仍然是蓝色的。以下是我使用的通用代码:
UIButton *iWantPlan = [UIButton buttonWithType:UIButtonTypeSystem];
iWantPlan.frame = CGRectMake(self.view.bounds.size.width/2-bgImageWidth/2, planBg.frame.origin.y + planBg.frame.size.height + 20, bgImageWidth, bgImageWidth/4+5);
iWantPlan.titleLabel.font = [UIFont systemFontOfSize:20];
[iWantPlan addTarget:self action:@selector(goToPersonalDetails) forControlEvents:UIControlEventTouchDown];
[self.view addSubview:iWantPlan];
iWantPlan.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
iWantPlan.imageView.frame = CGRectMake(bgImageWidth - 20, 10, 25, 25);
UIImage *viImage = [UIImage imageNamed:@"Icon_V.png"];
UIImage *viImageTap = [UIImage imageNamed:@"Icon_V_Tap.png"];
[iWantPlan setImage:viImage forState:UIControlStateNormal];
[iWantPlan setImage:viImageTap forState:UIControlStateSelected];
有解决办法吗?(顺便说一句,这确实令人沮丧:)使用:
imageWithRenderingMode:uiimagerenderingmodealways或original
确保没有蓝色背景:
UIImage *viImage = [[UIImage imageNamed:@"Icon_V.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *viImageTap = [[UIImage imageNamed:@"Icon_V_Tap.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
发件人:始终绘制原始图像,而不将其视为模板:
UIImageRenderingModeAlwaysOriginal
此外,这可以帮助您:
UIButton *iWantPlan = [UIButton buttonWithType:UIButtonTypeCustom];
...
[iWantPlan setImage:viImageTap forState:UIControlStateHighlighted];
只需将按钮的类型
uibuttonypesystem
更改为uibuttonypecustom