更改UILabel背景颜色

Abh*_*hek 2 iphone uilabel ios

我的代码是

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];
Run Code Online (Sandbox Code Playgroud)

如何更改标签的背景颜色?

小智 6

你想念

pTeamAlreadybl.backgroundColor=[UIColor anycolor];
Run Code Online (Sandbox Code Playgroud)

写下这段代码


Pla*_*gue 5

要更改UILabel的背景颜色,需要设置UILabel对象的backgroundColor属性.您可以使用以下代码行完成此操作:

[pTeamAlreadybl setBackgroundColor:[UIColor colorOfYourChoice]];
Run Code Online (Sandbox Code Playgroud)

要么

pTeamAlreadybl.backgroundColor = [UIColor colorOfYourChoice];
Run Code Online (Sandbox Code Playgroud)