Reputation: 44
I am trying to customize buttons of UIAlertView but however I am unable to achieve it, I am new to swift and I don't how to achieve.
Thank you so much.
Upvotes: 1
Views: 745
Reputation: 4503
To followup on @Dharmesh Kheni's answer, while you get no additional functionality for UIAlertViewController in swift, you can still use libraries in your swift code.
I work for Urban Outfitters and we have an open source customizable alert, URBNAlert
Here is some code, using URBNAlert in swift
let alert = URBNAlertViewController(title: "My Title", message: "Message")
alert.alertStyler.backgroundColor = UIColor.lightGrayColor()
alert.alertStyler.buttonHeight = 44
alert.alertStyler.buttonTitleColor = UIColor.redColor()
alert.alertStyler.cancelButtonBackgroundColor = UIColor.greenColor()
// many, many more things you can customize.
alert.addAction(URBNAlertAction(title: "Button Title", actionType: .Normal, actionCompleted: { (action) -> Void in
// do some stuff here when the user selects this button
}))
alert.show()
Upvotes: 0
Reputation: 71854
Simple answer is no you can not customise default alertViewController
buttons but you can achieve it by using custom alertView
.
HERE is some available libraries you can use.
Upvotes: 1