我不得不从XIB的几个ULABEL到代码,标签有白色背景。标签显示的是每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];

关于objective-c - UILabel在 subview 中具有白色背景,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13575343/

10-09 16:28