Reputation: 171
I want to change the top padding of a view to 80 when a button is toggled. How would this be done? Basically I want there to a space of 80 between the top of the view and the text.
Upvotes: 0
Views: 96
Reputation: 661
If you are using autolayout, then the easiest thing to do is to create a constraint for the distance between the text and the top of the view. You can connect it to a NSLayoutConstraint in code, and set the constraint.constant to the new value when the button is pressed.
@property (nonatomic, weak) IBOutlet NSLayoutConstraint *paddingConstraint;
// Somewhere after the button press
self.paddingConstraint.constant = 80;
Oh, and you will probably need to update the layout by calling this -
[self layoutIfNeeded];
Upvotes: 1