Setting UIButton image results in blue button in iOS 7

ios7, uibutton, uiimage

Solution

In iOS7 there is new button type called UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0), // standard system button

Check your .xib file and change button type to Custom

To do this programmatically, add this line to the `viewDidLoad`:

[UIButton buttonWithType:UIButtonTypeSystem]; 

Problem

On iOS 6 SDK I wrote the following lines of code to display an image inside a button: ``` NSURL *thumbURL2 = [NSURL URLWithString:@"http://example.com/thumbs/2.jpg"]; NSData *thumbData2 = [NSData dataWithContentsOfURL:thumbURL2]; UIImage *thumb2 = [UIImage imageWithData:thumbData2]; [btn2 setImage:thumb2 forState:UIControlStateNormal]; [self.view addSubview:btn2]; ``` But now with Xcode 5 and iOS 7 this doesn't work. The button doesn't contain the image. The button is filled with blue color.

Original source