I am really confused about constraints is iOS, i've read a lot of articles, but get stuck, when tried to set Height constraints of UIView according to UILabel content height. I know that is the common question, but i really don't understand the solutions. I thought that the main thing in this question is the constraint priority, but i can't set them properly. In one case, the height of UIView wont change to 0, and in other UILabel height does not make any sense.
So. I've got:
- UIView with height constraint, and descendants constraints (below)
- UIImageView with height=32, width=32, top=10, left=10, bottom>=10
- UILabel with left to UIImageView = 10, top=10, right=10, bottom=10
And i want:
- If i got any text to place in the UILabel, i want to dynamic height of UIView according to height of content size of UILabel.
- And if there is no text to place in UILabel, i want to set the height of UIView equals to 0 (hide the UIView totally).
UIImageView - is just the icon. If there is no text, must be shrink to 0, if there is some text, must have height 32, top constraint 10, bottom constraint more or equals to 10.
UPD:
Fix the problem, by adding height constraint programmatically. (don't like this)