iOS UIAlertController bold button changed in 8.3

From iOS 9 you can set the preferredAction value to the action which you want the button title to be bold.

    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) {}

The OK button which is on the right will be in bold font.

Leave a Comment

tech