Reputation: 3234
popup1
popup2
Is it possible to create single popup in storyboard & dynamically change - decrease/increase their height when error occurs (as shown in popup2)
I expect a correct approach to create such view.
Upvotes: 2
Views: 625
Reputation: 6704
One way to achieve this easily is by using a vertical UIStackView
in interface builder. For example, I have a simple stack view set up that contains two labels:
Now, in your view controller you can simply set your error label to hidden or not and the stack view will dynamically take care of the rest. e.g:
Without hiding anything:
Hiding error label:
[_errorLabel setHidden:YES];
Upvotes: 4
Reputation: 2259
You can do it. Just put Error view in the middle of the popup and when error occurs change height of this view (error, heightConstraint.constant = 50
, for example).
Then call
[self.view setNeedsUpdateConstraints];
[self.view updateConstraintsIfNeeded];
But important to note, that you should configure all constraints correctly that the popup view is stretched properly.
Upvotes: 0