开发者

How to make a blue button with white text?

开发者 https://www.devze.com 2022-12-24 22:40 出处:网络
// Make text white... and background blue [myButton setTitleColor:[UIColor w开发者_如何学ChiteColor] forState:UIControlStateNormal];
// Make text white... and background blue

[myButton setTitleColor:[UIColor w开发者_如何学ChiteColor] forState:UIControlStateNormal];
[myButton setBackgroundColor:[UIColor blueColor]];

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


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号