swift – 如何更改UIAlertController高度?
发布时间:2020-12-14 05:46:08 所属栏目:百科 来源:网络整理
导读:我创建了一个UIAlertController let alertC = UIAlertController(title: "Title",message: "Message",preferredStyle: UIAlertControllerStyle.Alert)alertC.addTextFieldWithConfigurationHandler(addTextField)alertC.addAction(UIAlertAction(title: "Can
我创建了一个UIAlertController
let alertC = UIAlertController(title: "Title",message: "Message",preferredStyle: UIAlertControllerStyle.Alert) alertC.addTextFieldWithConfigurationHandler(addTextField) alertC.addAction(UIAlertAction(title: "Cancel",style: UIAlertActionStyle.Default,handler: nil)) alertC.addAction(UIAlertAction(title: "OK",handler: okButton)) presentViewController(alertC,animated: true,completion: nil) 但之后我想改变UIAlertController的高度?我怎样才能做到这一点?
我发现在呈现视图控制器之前可以添加约束
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,completion: nil) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |