PappaSmalls
PappaSmalls

Reputation: 349

UILabel has a white background in a subview

I had to several of my UILabels from xib to code, and the labels have white backgrounds. The labels are displaying the date of a game which is being changed every 5 seconds. The text is perfectly fine, it just has a white background. I've tried backgroundColour and opaque, no results.

CGRect frame = CGRectMake(0, 278, 105, 33);
timerView = [[UIView alloc] initWithFrame:frame];
[self.view addSubview:timerView];

UIButton *timerBackground = [UIButton buttonWithType:UIButtonTypeCustom];
[timerBackground setBackgroundImage:[UIImage imageNamed:@"Time Background.png"] forState:UIControlStateNormal];
[timerBackground addTarget:self action:@selector(_addContactButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
timerBackground.frame = CGRectMake(-2 , 15, 102, 27);
[timerView addSubview:timerBackground];

dateDay = [[UILabel alloc] init];
dateDay.frame = CGRectMake(15, 5, 20, 21);
dateDay.opaque = NO;
[timerBackground addSubview:dateDay];

Upvotes: 3

Views: 291

Answers (1)

DrummerB
DrummerB

Reputation: 40221

Set the background color to clear.

label.backgroundColor = [UIColor clearColor];

Upvotes: 3

Related Questions