【问题标题】:iOS 8: UIAlertController Default Style Color [duplicate]iOS 8:UIAlertController 默认样式颜色 [重复]
【发布时间】:2014-10-19 07:37:07
【问题描述】:

我使用UIAlertControllerUIAlertAction的默认样式,但我在屏幕截图中得到白色背景上的白色文本

这是我的代码:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"0237826726" style:UIAlertActionStyleDefault
                                                              handler:^(UIAlertAction * action) {
                                                                    [self callPlaceNumber:@"0237826726"];
                                                              }];
[alert addAction:defaultAction];

UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault
                                                   handler:^(UIAlertAction * action) {
                                                       [alert dismissViewControllerAnimated:YES completion:nil];
                                                   }];

[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:nil];

我搜索了问题,发现可以为UIAlertController添加tintColor,如下所示,但没有成功。

alert.view.tintColor = [UIColor blackColor];

这是正常行为还是我的代码有什么问题?

【问题讨论】:

标签: ios ios8 uialertcontroller


【解决方案1】:

可以通过外观 API 为 UIAlertController 设置色调颜色:

[[UIView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor blackColor]];

【讨论】:

  • @AndreaZ 嗨.. 我成功地更改了 UIAlertAction 中添加的附件视图的色调,但仍然无法将 UIAlertAction 按钮标题的文本从白色更改为所需的文本。还有什么要补充的吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-08-27
  • 2016-04-27
  • 1970-01-01
  • 2014-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多