3

I've had this problem before but was able to work around it until now, Basically I'm creating a custom UIbutton setting its image as a uiimage and then the button that has had a label until I implimented the below code now loses its label. I need that label because it is set programatically in code that follows.

 NSString *imageName = [NSString stringWithFormat:kNameOfButtonimage ];
            UIImage *image = [UIImage imageNamed:imageName];
            [button setImage:image forState:UIControlStateNormal ];

Any help you could lend would be mucho appreciated.

-nick

nickthedude
  • 4,925
  • 10
  • 36
  • 51

1 Answers1

5

I needed to do a:

[button setBackroundImage:image forState:UIControlStateNormal ];

instead of this:

[button setImage:image forState:UIControlStateNormal ];

;)

nickthedude
  • 4,925
  • 10
  • 36
  • 51
  • I discovered the same applies for titleColor too, i.e this `[buttonTemp setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];` instead of this: `buttonTemp.titleLabel.textColor = [UIColor blackColor];` – Ted Oct 26 '12 at 11:53