Swift – UIAlertcontrller上textfield的大小

我想增加UIAlertController的UITextField的初始高度。 这是我的代码:

let reportAlertController = UIAlertController(title: "Report", message: "If you find anything to report, please write it in the text box below and press send. To cancel report, press cancel.", preferredStyle: .Alert) reportAlertController.addTextFieldWithConfigurationHandler({ (tf) -> Void in tf.frame.size.height = 1500 tf.placeholder = "Report detail(s) here" }) reportAlertController.addAction(UIAlertAction(title: "Send", style: UIAlertActionStyle.Default, handler: nil)) reportAlertController.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil)) presentViewController(reportAlertController, animated: true, completion: nil) 

事情是,即使我重新分配的框架大小,它不反映在警报。 任何帮助将不胜感激。

编辑:或者我想知道的方式来扩大高度,因为它达到了宽度的尽头。

试试:

  let reportAlertController = UIAlertController(title: "Report", message: "If you find anything to report, please write it in the text box below and press send. To cancel report, press cancel.", preferredStyle: .Alert) reportAlertController.addTextFieldWithConfigurationHandler({ (tf) -> Void in tf.frame.size.height = 1500 tf.placeholder = "Report detail(s) here" }) reportAlertController.addAction(UIAlertAction(title: "Send", style: UIAlertActionStyle.Default, handler: nil)) reportAlertController.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil)) presentViewController(reportAlertController, animated: true, completion: nil) reportAlertController.addAction(UIAlertAction(title: "Send", style: UIAlertActionStyle.Default, handler: nil)) reportAlertController.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil)) presentViewController(reportAlertController, animated: true, completion: { () -> Void in self.layoutIfNeeded() //Update frame })