繁体   English   中英

我们可以快速更改UIAlertController Buttons的高度和宽度吗?

[英]Can we change the height and width of UIAlertController Buttons in swift

我想快速自定义UIAlertviewcontroller的控件,并快速更改“取消”和“确定”按钮的宽度和高度。 有什么办法可以做到这一点? 与此类似

请尝试以下代码:-

////更改警报视图控制器的高度

*

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)

*

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM