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. eg:
Without hiding anything:
Hiding error label:
[_errorLabel setHidden:YES];
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.