Objective c UILabel在子视图中具有白色背景

Objective c UILabel在子视图中具有白色背景,objective-c,Objective C,我必须将我的几个UIB标签从xib转换为代码,标签有白色背景。标签显示每5秒更改一次的游戏日期。文本非常好,只是有一个白色的背景。我试过背景色和不透明,没有结果 CGRect frame = CGRectMake(0, 278, 105, 33); timerView = [[UIView alloc] initWithFrame:frame]; [self.view addSubview:timerView]; UIButton *timerBackground = [UIButton bu

我必须将我的几个UIB标签从xib转换为代码,标签有白色背景。标签显示每5秒更改一次的游戏日期。文本非常好,只是有一个白色的背景。我试过背景色和不透明,没有结果

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];

将背景色设置为“清除”

label.backgroundColor = [UIColor clearColor];

UILabel
从UIView扩展而来。所有视图都具有此属性。在查看类的参考文档时,不要忘记查看父类(以及祖父母类等)的文档。