iOS UIAlertController 粗体按钮在 8.3 中更改

标签 ios button uialertcontroller

带有两个样式设置按钮的 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/

相关文章:

css - 我的按钮背景似乎被拉长了

ios - UIAlertController 处理关闭点击外部 (iPad)

ios - 尽管没有错误,AVPlayer 仍无法播放音频

iOS : Internet connection is available but getting time out error in web service call , 相同的网络服务在 android 中运行

ios - 在 opengles 中渲染三角形

iphone - 使用系统图标或图像图标的自定义导航栏按钮

javascript - 为什么 Canvas 上下文 drawImage 在 iPhone 上失败

jQuery移动按钮默认旋转90°并添加到网格

ios - 如何在 WKWebView 中关闭 ipad 的 alertController

swift - 禁用 Swift UIAlertController 按钮,直到输入经过验证