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:
And i want:
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.
Fix the problem, by adding height constraint programmatically. (don't like this)
You can make the constraints take full control of the label,image and view heights, if you set the priorities correctelly.
Like this
The View is this
and this
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.