Reputation: 3145
I have two views (UILabels
) on my view controller with next layout:
I want to recalculate constraints after device orientation is changed, so my top label should take only one line and bottom label should move up to keep the same offset from top label (top label is aligned vertically in container).
How can I achieve it?
If I try to use [self.toplabel sizeToFit];
it breaks all my size constraint to set new size and, that's important for me, neglect vertical space between these two labels.
I've tried:
[self.longLabel sizeToFit];
[self.botLabel layoutIfNeeded];
[self.botLabel setNeedsUpdateConstraints];
[self.botLabel updateConstraintsIfNeeded];
[self.botLabel needsUpdateConstraints];
But with no result. Constraint don't want to recalculate themselves.
Upvotes: 1
Views: 861
Reputation: 4005
Did you try [label sizeToFit];
after change the Orientation.
You can call is with notification method after every orientation change
Upvotes: 1