Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IOS 7按钮图像颜色_Ios_Objective C_Ios7_Uibutton_Uiimage - Fatal编程技术网

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