Part of my UIButton
is an UIImage
, and IOS 7 changes its color from black to blue. I tried the solution offered around here: changing the button type to UIButtonTypeSystem
but that doesn't help and the image is still blue. Here's the generic code I'm using:
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];
Is there a solution? (and just as an aside, this is really frustrating :)
With: imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal
sure you don't have the blue background:
UIImage *viImage = [[UIImage imageNamed:@"Icon_V.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *viImageTap = [[UIImage imageNamed:@"Icon_V_Tap.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
From Apple Documentation UIImageRenderingMode:
Always draw the original image, without treating it as a template: UIImageRenderingModeAlwaysOriginal
Also, that can help you:
UIButton *iWantPlan = [UIButton buttonWithType:UIButtonTypeCustom];
...
[iWantPlan setImage:viImageTap forState:UIControlStateHighlighted];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With