Reputation: 203
I have create a collection view in my storyboard and add constraints. Now I need to change the collection view constraint for a specific condition and I want to do it programmatically in my class. I have an IBOutlet for the collection view. What parameter needs to be changed?
Upvotes: 1
Views: 1175
Reputation: 182
nameOfYourConstraint.constant = 100 // Int
Upvotes: 2
Reputation: 16456
First create IBOutlet
of constraints required to changed by dragging to ViewController
The constant
value needs to be cahnged, e.g.:
self.outlet.constant = 50
Don't forget to call self.view.layoutIfNeeded
after modifying the constant.
Upvotes: 1
Reputation: 434
You need to create IBOutlets of the constraints, and update the constraints value according to your condition.
Upvotes: 1