0

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

mirza
  • 77
  • 3
  • 11

1 Answers1

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

*

  • 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