I have a set of UIButtons mapped out in IB. I want to randomly add images to a few buttons for each round of an education game.
You can see some images stashed at the top of the page:
As you can also see, the images in the buttons are blue. So, what am I doing wrong (i.e. why are they blue?)? Are they being set as background images?
I'm adding the images as follows:
int tmpTag0 = [[currentButtonArray objectAtIndex:0] integerValue];
UIButton *tmpButton0 = (UIButton *)[self.view viewWithTag:tmpTag0];
[tmpButton0 setImage:[UIImage imageNamed:temp1] forState:UIControlStateNormal];
........
int tmpTag4 = [[currentButtonArray objectAtIndex:4] integerValue];
UIButton *tmpButton4 = (UIButton *)[self.view viewWithTag:tmpTag4];
[tmpButton4 setImage:[UIImage imageNamed:temp5] forState:UIControlStateNormal];
currentButtonArray is an array of 5 random button indexes that correspond to 5 button tags.
Thanks very much for any ideas.
What I'm seeing when I look for UIButton in Xcode help:
UPDATE: With help from folks below, this worked for me:
int tmpTag0 = [[currentButtonArray objectAtIndex:0] integerValue];
UIButton *tmpButton0 = (UIButton *)[self.view viewWithTag:tmpTag0];
UIImage *buttonImage0 = [UIImage imageNamed:temp1];
buttonImage0 = [buttonImage0 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
[tmpButton0 setImage:buttonImage0 forState:UIControlStateNormal];