I don't want to change UILabel.appearance
as it will apply to all labels.
How I can show UIAlertController
that will look like below image?
Need to show bold button in the second position.
By default, when I am setting UIAlertActionStyle.cancel
it shows it on the Confirm button in the first position.
It looks like this now:
I did some research but I didn't find any solution.
Swift 4.2/Swift 5
You need to set preferred action method,
//Create alertController
let alert = UIAlertController(title: "title", message: "message", preferredStyle: .alert)
//Create and add the Confirm action
let confirmAction = UIAlertAction(title: "Confirm", style: .default, handler: { (action) -> Void in
//Do Something here...
})
alert.addAction(confirmAction)
//Create and add the Cancel action
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) -> Void in
//Do Something here...
})
alert.addAction(cancelAction)
// Set Preferred Action method
alert.preferredAction = confirmAction
self.present(alert, animated: true, completion: nil)
The output will be,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With