带有两个样式设置按钮的 UIAlertController:
UIAlertActionStyle.Cancel
UIAlertActionStyle.Default
在 iOS 8.2 中,取消按钮是非粗体的,默认是粗体的。 在 iOS 8.3 中,它们已经切换了
你可以看到苹果自己的应用程序,例如设置>邮件>添加帐户> iCloud>输入无效数据,然后在8.3上显示如下:
不支持的 Apple ID
了解更多(粗体) OK(非粗体)
而 8.2 则相反。
让它再次像 8.2 一样的任何解决方法。为什么变了?
最佳答案
从 iOS 9 开始,您可以将 preferredAction
值设置为您希望按钮标题为粗体的操作。
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) {}
右侧的确定按钮将以粗体显示。
关于iOS UIAlertController 粗体按钮在 8.3 中更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29590534/