Change UILabel background color
my code is
UILabel *pTeamAlreadybl=[[UILabel alloc]initWithFrame:CGRectMake(110, 275,180,30)];
pTeamAlreadybl.text=@" Team already?";
pTeamAlre开发者_运维问答adybl.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?
You miss
pTeamAlreadybl.backgroundColor=[UIColor anycolor];
write this code
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];
pTeamAlreadybl.backgroundColor = [UIColor ...];
Doesn't the above code work?
[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]
精彩评论