Reputation: 381
I was wondering whether it was possible to set constraints which reference a variable and adjust dynamically according to an integer or float value?
Thanks D
Upvotes: 0
Views: 524
Reputation: 2697
First of all, you should declare outlet
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *view1TopConstraint;
Then you should link this outlet in interface builder like you link any other outlets.
Finally, in your code where it is necessary, do:
view1TopConstraint.constant = 50.f;
Of course everything depends on complexity of your logic, somewhere this approach is simpler, but in big things you'd better to use VFL. See https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage/VisualFormatLanguage.html
Upvotes: 1