I have a ViewController which has a tableview in it. I set its autolayout manually. Now I'm trying to change the autolayout constraints programmatically. How can I do that?
This is my code's screenshot
Thanks
You can change constraints programatically without any outlet:
for (_, value) in self.view.constraints.enumerate() {
let constraint = value as NSLayoutConstraint
if constraint == .Height {
if value.firstItem.isEqual(self.tableView) {
constraint.constant = 200.0
}
}
}
Follow these steps
eg. @IBOutlet weak var heightConstraint: NSLayoutConstraint!
update constant, heightConstraint.constant = 100.
为需要修改的约束设置出口并将其连接起来。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.