I have a ViewController with a tableView. I\'ve set it up in the Storyboard. Is there a way to set the constraints for the tableView programmatically? I\'ve tried to set a I
You mentioned in one of your comments that you want to change the constraints when the user presses a button. You can achieve this in less code by making an outlet to the constraint. Find the constraint in the document outline page and CTRL + Drag to your class to create an outlet to the constraint. Then you can change the constant in code easier.
@IBOutlet weak var topConstraint: NSLayoutConstraint!
@IBOutlet weak var bottomConstraint: NSLayoutConstraint!
func buttonPressed() {
if (/* some condition */) {
self.topConstraint.constant += 8
self.bottomConstraint.constant += 8
} else {
// Return the constraints to normal, or whatever you want to do
}
}