[_firstPrincipleButton setBackgroundImage:[UIImage imageNamed:@"i_press.png"]
forState:UIControlStateNormal];
The above code is working fine in iOS7 but in iOS7.1 this is not changing the image of UIButton. I have also tried to do this with setImage but didn't work.
Thanks
Just in case that others have the same problem and need another hint on how to fix this:
I also had this problem and finally found out that setting a button's (background) image doesn't work on iOS 7.1, if the button is disabled.
Not sure if this fixes your problem, but it was mine. Calling setNeedsLayout
didn't help in my case, unfortunately. What you can do as a workaround is either to override UIButton or to add a category that contains a method like the following to set an image:
- (void)setImage:(UIImage *)img forButtonState:(UIControlState)state
{
BOOL shouldEnable = self.enabled;
self.enabled = YES;
[self setImage:img forState:state];
self.enabled = shouldEnable;
}
Filed a bug report for this issue (16497031).
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