在8.3中更改iOS UIAlertController粗体button

UIAlertController带有两个样式设置的button:

UIAlertActionStyle.Cancel UIAlertActionStyle.Default 

在iOS 8.2中,取消button不是粗体,默认为粗体。 在iOS 8.3中,他们已经轮换了

你可以看到苹果自己的应用程序,例如设置>邮件>添加账户> iCloud>input无效数据,然后在8.3上显示:

不支持的Apple ID

了解更多(粗体)确定(非粗体)

而另一方面则是8.2。

任何解决方法,使它像8.2再次。 它为什么改变了?

从iOS 9开始,您可以将preferredAction值设置为您希望button标题为粗体的操作。

  let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil) let OKAction = UIAlertAction(title: "OK", style: .Default, handler: nil) alert.addAction(cancelAction) alert.addAction(OKAction) alert.preferredAction = OKAction presentViewController(alert, animated: true) {} 

右侧的OKbutton将以粗体显示。

这是对SDK的有意更改。 我刚才在这个问题上得到了苹果对这个雷达的回应,他说:

这是一个有意的改变 – 取消button将在警报中加粗。

不幸的是,我无法在各种更改日志中find任何提及这一点的内容。

所以,我们需要在某些地方对应用程序进行更改,以使某些事情合理。

我只是在iOS 8.2中检查: 第一个添加的button是非粗体的, 第二个添加的button是粗体的。 通过这个代码,取消button将变为粗体:

 [alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil]]; [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; 

在这个代码中,一个默认的button将是粗体的:

 [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; [alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:nil]]; 

我现在无法检查iOS 8.3,但这种行为可能是一个原因。