How to change UIAlertController height?

后端 未结 5 1777
轻奢々
轻奢々 2020-12-05 18:52

I created an UIAlertController

let alertC = UIAlertController(title: \"Title\", message: \"Message\", preferredStyle: UIAlertControllerStyle.Alert)
alertC.ad         


        
5条回答
  •  囚心锁ツ
    2020-12-05 19:17

    Swift 5

            let alert = UIAlertController(title: "Title", message: "New Message", preferredStyle: UIAlertController.Style.alert)
    
            let height:NSLayoutConstraint = NSLayoutConstraint(item: alert.view!, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 350)
            alert.view.addConstraint(height)
    
    
            let okAction = UIAlertAction(title: "Done", style: .default, handler: {
                (alert: UIAlertAction!) -> Void in
                // Perform Action
            })
            alert.addAction(okAction)
            let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
            alert.addAction(cancelAction)
            self.present(alert, animated: true, completion: nil)
    

提交回复
热议问题