这是我的密码
func弹出控制器()
{
let alert=uiAlertController(标题:“附加说明”,消息:“在此处编写附加说明。”,首选样式:.alert)
让textView=uitextView())
textView.autoResizingMask=[.flexiblewidth,.flexibleheight]
设为color=ui颜色(红色:224/255,绿色:224/255,蓝色:224/255,alpha:1.0)。cgcolor
textView.layer.borderColor=颜色
textView.layer.borderWidth=1.0
textview.layer.cornerradius=5.0
让controller=myActivitiesViewController()。
textView.frame=控制器.view.frame
controller.view.addSubView(文本视图)
alert.setvalue(控制器,forkey:“contentviewcontroller”)。
让height:nslayoutConstraint=nslayoutConstraint(项:alert.view,属性:.height,relatedby:.equal,toitem:nil,属性:.notanattribute,乘数:1,常量:180)
alert.view.addConstraint(高度)
let saveaction=uiAlertAction(标题:“OK”,样式:.default,处理程序:nil)
let cancelaction=uiAlertAction(标题:“cancel”,样式:.cancel,处理程序:nil)
alert.addaction(保存操作)
alert.addaction(取消操作)
自我呈现(警报,动画:真,完成:{
textView.becomeFirstResponder()。
})
}
< /代码> <静态地
截图

这是我的密码
func popUpController()
{
let alert = UIAlertController(title: "Additional Notes", message: "Write your additional notes here.", preferredStyle: .alert)
let textView = UITextView()
textView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
let color = UIColor(red: 224/255, green: 224/255, blue: 224/255, alpha: 1.0).cgColor
textView.layer.borderColor = color
textView.layer.borderWidth = 1.0
textView.layer.cornerRadius = 5.0
let controller = MyActivitiesViewController()
textView.frame = controller.view.frame
controller.view.addSubview(textView)
alert.setValue(controller, forKey: "contentViewController")
let height: NSLayoutConstraint = NSLayoutConstraint(item: alert.view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 180)
alert.view.addConstraint(height)
let saveAction = UIAlertAction(title: "OK", style: .default, handler: nil)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
alert.addAction(saveAction)
alert.addAction(cancelAction)
self.present(alert, animated: true, completion: {
textView.becomeFirstResponder()
})
}