2010-03-23 48 views
4
// Make text white... and background blue 

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

应该用白色文字和蓝色背景制作一个按钮吗? 它没有。如何制作带有白色文字的蓝色按钮?

+1

那么会发生什么? – stefanB 2010-03-23 23:18:25

+0

它看起来像一个没有文字的按钮。只是按钮的* CORNERS *变为蓝色。 – Susanna 2010-03-24 00:32:51

回答

0

按钮上的buttonStyle是什么?这会影响颜色设置的外观。你可能会尝试不同的按钮样式,直到找到一个看起来不错的按钮。

3

听起来像你的按钮是UIButtonTypeRoundedRect类型。下面的链接应该回答你的问题。

Is it even possible to change a UIButtons background color?

什么,但是我要做的只是不给它一个类型。

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

虽然看起来不像那样花哨。

相关问题