我不得不将我的几个 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];