更改 UILabel 背景颜色
我的代码是
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];
如何更改标签的背景颜色?
my code is
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];
How can I change label's background color?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你错过了
写这段代码
You miss
write this code
要更改UILabel的背景颜色,您需要设置UILabel对象的backgroundColor属性。您可以使用以下代码行来执行此操作:
或者
To change the background color of a UILabel, you need to set the backgroundColor property of the UILabel object. You can do so by using the following line of code:
OR
上面的代码不行吗?
Doesn't the above code work?
YourColor如下所述
blackColor;
深灰色;
浅灰色
白色;
灰色;
红色;
绿色;
蓝色;
青色;
黄色;
洋红色;
橙色;
紫色;
棕色;
清晰的颜色;
你也可以像这样使用自定义颜色
YourColor as mentioned below
blackColor;
darkGrayColor;
lightGrayColor
whiteColor;
grayColor;
redColor;
greenColor;
blueColor;
cyanColor;
yellowColor;
magentaColor;
orangeColor;
purpleColor;
brownColor;
clearColor;
you can use customized color as well like this