开发者

How to make a blue button with white text?

// 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜