Ted pottel
Ted pottel

Reputation: 6983

adding UILabel in Objective-C, change Background Color

I add a UILabel using objective c, have a white rectagle around them. How do I remove this rectangle so the background shows through? I looked in the documnetion for uilabel view and did not see anything per to background. code

UILabel *mContact=[ [UILabel alloc] initWithFrame:CGRectMake(273,442,32,20)];
mContact.text=@"Contact";
mContact.font=[UIFont fontWithName:@"Helvetica" size:9.0 ];
[self.view addSubview:mContact];    

-Ted

Upvotes: 1

Views: 4758

Answers (3)

chown
chown

Reputation: 52748

Try this out:

myLabel.backgroundColor = [UIColor clearColor];

--or--

myLabel.backgroundColor = [UIColor whateverColorYouWant];

Also, check out the UILabel Class Reference

Upvotes: 1

Mundi
Mundi

Reputation: 80273

[mContact setBackgroundColor:[UIColor clearColor];
//or
mContact.backgroundColor = [UIColor clearColor];

Upvotes: 0

zaph
zaph

Reputation: 112857

UILabel has a background property it inherits from UIView, set it to clear:

@property(nonatomic, copy) UIColor *backgroundColor

mContact.backgroundColor = [UIColor clearColor];

Upvotes: 2

Related Questions