我有几个我的UILabel从xib到代码,标签有白色背景。标签显示每5秒更改一次的游戏日期。文字非常好,只有白色背景。我尝试过backgroundColour和opaque,没有结果。
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];
答案 0 :(得分:3)
将背景颜色设置为清除。
label.backgroundColor = [UIColor clearColor];