更改 UILabel 背景颜色

发布于 2024-11-28 05:27:13 字数 459 浏览 4 评论 0原文

我的代码是

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

你曾走过我的故事 2024-12-05 05:27:13

你错过了

pTeamAlreadybl.backgroundColor=[UIColor anycolor];

写这段代码

You miss

pTeamAlreadybl.backgroundColor=[UIColor anycolor];

write this code

挽清梦 2024-12-05 05:27:13

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

[pTeamAlreadybl setBackgroundColor:[UIColor colorOfYourChoice]];

或者

pTeamAlreadybl.backgroundColor = [UIColor colorOfYourChoice];

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:

[pTeamAlreadybl setBackgroundColor:[UIColor colorOfYourChoice]];

OR

pTeamAlreadybl.backgroundColor = [UIColor colorOfYourChoice];
谁的年少不轻狂 2024-12-05 05:27:13
pTeamAlreadybl.backgroundColor = [UIColor ...];

上面的代码不行吗?

pTeamAlreadybl.backgroundColor = [UIColor ...];

Doesn't the above code work?

甜柠檬 2024-12-05 05:27:13
[pTeamAlreadybl setBackgroundColor:[UIColor YourColor]];

YourColor如下所述

blackColor;
深灰色;
浅灰色
白色;
灰色;
红色;
绿色;
蓝色;
青色;
黄色;
洋红色;
橙色;
紫色;
棕色;
清晰的颜色;

你也可以像这样使用自定义颜色

[UIColor colorWithRed:61.0/255.0 green:61.0/255.0 blue:61.0/255.0 alpha:0.6]
[pTeamAlreadybl setBackgroundColor:[UIColor YourColor]];

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

[UIColor colorWithRed:61.0/255.0 green:61.0/255.0 blue:61.0/255.0 alpha:0.6]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文