UIView extension as UILabel inside grows

I have UIViewwhich is a superview UIImageViewand UILabel. UILabel may have a different size depending on the amount of text in it. Therefore, I need UIViewto grow and contract with UILabel, but cannot make it work.

Screenshot as it looks below:

enter image description here

As you can see, the distance between the label and above it is too great. In .xibI set the upper and lower limits on UILabeljust 10, but, apparently, they are somehow violated. UIViewhas an upper limit for the frame above with an image like >=10so that it can grow from 10.

You can see .xibbelow:

enter image description here

Content Hugging Priority UIView, . UILabel 4 : , , , UIView. Content Hugging Priority UILabel UIView, . UIImageView - UIView, .

+4
3

, :

:

  • : a >= 20

:

  • : 0
  • : ()
  • : a >= 10

:

enter image description here

:

+4

, , UILabel UIImageView, Content Compression Resistance Priority 250. . matt! github , Content Compression Resistance Priority of UIImageView 250 - .

+1

.sizeToFit() InterfaceBilder 0, ( ), > =/< = . , , , . / , , - . , .

0
source

Source: https://habr.com/ru/post/1626057/


All Articles