How to make a blue button with white text?

// Make text white... and background blue [myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [myButton setBackgroundColor:[UIColor blueColor]]; 

Should it do a button with white text ... and a blue background? This is not true.

+4
source share
2 answers

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

Is it possible to change the background color of UIButtons?

What I do just doesn't give him a type.

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

It doesn't seem like that.

+3
source

What is the button on this button? This will affect how the color settings look. You can try different styles of buttons until you find one that looks right.

0
source

Source: https://habr.com/ru/post/1304934/


All Articles