swift – 如何更改UIAlertController高度?

swift – 如何更改UIAlertController高度?,第1张

概述我创建了一个UIAlertController let alertC = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)alertC.addTextFieldWithConfigurationHandler(addTextField)alert 我创建了一个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)
总结

以上是内存溢出为你收集整理的swift – 如何更改UIAlertController高度?全部内容,希望文章能够帮你解决swift – 如何更改UIAlertController高度?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1049554.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存