let containerViewWidth = 250
let containerViewHeight = 120
let containerFrame=CGRect(x: 10, y: 70, width: CGFloat(containerViewWidth), height: CGFloat(containerViewHeight))
let label=UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
label.text="anusha"
var containerView: UIView = UIView(frame: containerFrame);
containerView.addSubview(label)
alert.view.addSubview(containerView)
// now add some constraints to make sure that the alert resizes itself
let cons:NSLayoutConstraint = NSLayoutConstraint(item: alert.view, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.greaterThanOrEqual, toItem: containerView, attribute: NSLayoutAttribute.height, multiplier: 1.00, constant: 130)
alert.view.addConstraint(cons)
var cons2:NSLayoutConstraint = NSLayoutConstraint(item: alert.view, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.greaterThanOrEqual, toItem: containerView, attribute: NSLayoutAttribute.width, multiplier: 1.00, constant: 20)
alert.view.addConstraint(cons2)
alert.addAction(UIAlertAction(title: "Close", style: UIAlertActionStyle.default, handler: nil))
後我添加視圖....關閉按鈕是不工作...如何使這項工作?的iOS警報視圖控制器
好友,和我的關閉按鈕應該在容器下面查看...應該做什麼? –