Change constraints based on device during run time
autolayout, constraints, ios, storyboard
Solution
You can define a macro to determine the screen size, like the following:
#define isiPhone4 ([[UIScreen mainScreen] bounds].size.height == 480)?TRUE:FALSE
Later in the code you can do something like this:
if (isiPhone4) {
self.constraint.constant = NEW_VALUE;
}
To access storyboard constraints from code you should make `IBOutlets` for them (control+drag them into your controller like anything else).
Problem
I'm using Storyboard to set my constraints. While everything is perfect, I have a some views where I wish to change the constraints on only 3.5" devices. Is this possible? How can I do it?