I want to customize the controls of UIAlertviewcontroller in swift and Change the width and height of the Cancel and OK buttons in swift. Is there any way possible to achieve this?Just similar to this
Asked
Active
Viewed 4,071 times
0
-
I have given this link below: - http://stackoverflow.com/questions/25379559/custom-alert-uialertview-with-swift – Tejveer Sambariya May 20 '17 at 09:15
-
you can see and check it. – Tejveer Sambariya May 20 '17 at 09:16
-
Like this -> https://i.stack.imgur.com/utlYw.jpg – mirza May 20 '17 at 09:22
-
I don't think so. I have tried to change color/tint color of different layers which is working fine, but for control's size better you go with custom... Please update me if you find anything on this. Thanks – Ashwin Kanjariya May 20 '17 at 10:48
1 Answers
-1
Please try this code : -
//// change the height of alert view controller
*
let alertController = UIAlertController(title: nil, message: "hello", preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in
// hide action sheet
}
alertController.addAction(cancelAction)
var height:NSLayoutConstraint = NSLayoutConstraint(item: alertController.view, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: self.view.frame.height * 0.80)
alertController.view.addConstraint(height);
self.presentViewController(alertController, animated: true, completion: nil)
*

Tejveer Sambariya
- 271
- 3
- 13
-
OP wants to change width and height of the Cancel and OK buttons not the entire view. – Rishab May 20 '17 at 09:42
-
@Tejveer , my requirement is quite clear, i don't want to change height of alertview only the width and height of buttons – mirza May 20 '17 at 10:07