我的代码是
UILabel *pTeamAlreadybl=[[UILabel alloc]initWithFrame:CGRectMake(110, 275,180,30)];
pTeamAlreadybl.text=@" Team already?";
pTeamAlreadybl.font=[UIFont boldSystemFontOfSize:16];
pTeamAlreadybl.textAlignment=UITextAlignmentLeft;
pTeamAlreadybl.textColor=[UIColor colorWithRed:61.0/255.0 green:61.0/255.0 blue:61.0/255.0 alpha:0.6];
pTeamAlreadybl.shadowColor = [UIColor colorWithWhite:1.0 alpha:0.7];
如何更改标签的背景颜色?
答案 0 :(得分:6)
你错过了
pTeamAlreadybl.backgroundColor=[UIColor anycolor];
编写此代码
答案 1 :(得分:5)
要更改 UILabel 的背景颜色,您需要设置UILabel对象的 backgroundColor 属性。您可以使用以下代码行来执行此操作:
[pTeamAlreadybl setBackgroundColor:[UIColor colorOfYourChoice]];
OR
pTeamAlreadybl.backgroundColor = [UIColor colorOfYourChoice];
答案 2 :(得分:1)
pTeamAlreadybl.backgroundColor = [UIColor ...];
上述代码不起作用吗?
答案 3 :(得分:0)
[pTeamAlreadybl setBackgroundColor:[UIColor YourColor]];
YourColor如下所述
blackColor;
darkGrayColor;
lightGrayColor
whiteColor;
grayColor;
redColor;
绿彩;
blueColor;
cyanColor;
黄色颜色;
magentaColor;
orangeColor;
purpleColor;
brownColor;
clearColor;
你也可以像这样使用自定义颜色
[UIColor colorWithRed:61.0/255.0 green:61.0/255.0 blue:61.0/255.0 alpha:0.6]