我想在swift中自定义UIAlertviewcontroller的控件,并在swift中更改Cancel和OK按钮的宽度和高度。 有没有办法实现这个目标?Just similar to this
答案 0 :(得分:-1)
请尝试以下代码: -
//// 更改警报视图控制器的高度
*
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)
*