I create a UICollectionView and add one cell, which only subview is UIButton. This button has its own title and image. I checked that the image data is correct in the debugger.
When the button is drawn on the screen, I see the text and the image, however, the image looks as if it was filled with the color of the hue, obscuring the entire image other than its shape.
What am I missing here to show this as a regular button?
Update
It turns out that this does not apply to UICollectionView, but applies to all UIButtons in iOS7.
iOS 7 makes all the images in the buttons behave like template images using the image's alpha channel, along with the hue color, to create an image (similar to images on the tab bar). UIImage has a new renderMode property, which is considered βautomaticβ by default, which allows the context to decide (template style for buttons)
This can be circumvented using the new imageWithRenderingMode : method in UIImage:
UIImage* myImage = [UIImage imageNamed:@"Foo.png"]; myImage = [myImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; [button setImage:myImage forState:UIControlStateNormal];
ios objective-c ios7 uibutton uiimage
Code monkey
source share