我的应用程序中有一个按钮,在iOS7上完全可见。但是当我切换到iOS8时,不会出现此按钮的标题标签。我只能看到按钮周围的边框。 这是制作按钮的代码。有人能给我提供问题的线索吗?iOS8 UIButton标题消失
UIButton *problem = [[UIButton alloc] initWithFrame:frame];
[problem addTarget:self action:@selector(problemButton:) forControlEvents:UIControlEventTouchUpInside];
problem.backgroundColor = [UIColor whiteColor];
[problem setTitle:NSLocalizedString(@"ReportAProblem", nil) forState:UIControlStateNormal];
problem.titleLabel.textColor = CUSTOM_DARK_GRAY_COLOR;
[[problem layer] setBorderWidth:1.0f];
[[problem layer] setBorderColor:CUSTOM_DARK_GRAY_COLOR.CGColor];
problem.layer.cornerRadius = 5;
problem.clipsToBounds = YES;
我发现这个问题的答案,但马上有另: 我遇到了同样的问题,我的一些UILabels,例如:
self.label = [[UILabel alloc] initWithFrame:labelFrame];
self.label.numberOfLines = 1;
self.label.adjustsFontSizeToFitWidth = YES;
self.label.textAlignment = NSTextAlignmentCenter;
self.label.textColor = self.textColor;
CGFloat fontSize = self.bounds.size.height/5;
self.label.font = [UIFont systemFontOfSize:fontSize];
好吧,我突然发现自己的答案。我只是不得不添加'[问题setTitleColor:CUSTOM_DARK_GRAY_COLOR forState:UIControlStateNormal];'我的代码 – Thorax 2014-09-19 12:29:10
你为什么要设置你的视图高度的字体大小的比例?也许用你的标签做更有意义。 'CGFloat fontSize = self.label.bounds.size.height/5;' – Starscream 2014-09-19 12:36:59