4
// Make text white... and background blue

[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setBackgroundColor:[UIColor blueColor]];

Should that make a button with white text... and a blue background? It doesn't.

Ben Zotto
  • 70,108
  • 23
  • 141
  • 204
Susanna
  • 771
  • 3
  • 10
  • 17

2 Answers2

3

It sounds like your button is of the UIButtonTypeRoundedRect type. The link below should answer your question.

Is it even possible to change a UIButtons background color?

What I do however is just not give it a type.

UIButton *myButton = [[UIButton alloc] init];
[myButton setBackgroundColor:[UIColor blueColor]];
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

Doesn't look quite as fancy like that though.

Community
  • 1
  • 1
hemlocker
  • 1,012
  • 1
  • 9
  • 24
0

What's the buttonStyle on that button? That'll affect how the color settings make it look. You might try different button styles until you find one that looks right.

codewarrior
  • 2,000
  • 14
  • 14