I have the following 3 components within a Horizontal stack view.
- Yellow
UILabel
- Red
UIImageView
- Green
UIImageView
The distribution for the Horizontal stack view is Fill.
The content mode for UIImageView
is Aspect fit. They are using SFSymbol named "pin.fill".
The number of line for UILabel
is 0, so that it supports multilines.
All the 3 components are having same Content Hugging Priority (250) and Content Compression Resistance Priority (750)
When Horizontal Content Compression Resistance for UILabel is 750 to 998
My questions are
- Why the red
UIImage
take up most space, even though all 3 of them are having same Content Hugging Priority (250) and Content Compression Resistance Priority (750)? - My intention is letting yellow
UILabel
fill up most space. However, I can only achieve so, if I increase the Horizontal Content Compression Resistance (ForUILabel
only) up to 999 or 1000. I thought, as long as any value is higher than 750 will be good enough? Does 999 or 1000 value in Horizontal Content Compression Resistance carry any special meaning?
When Horizontal Content Compression Resistance for UILabel is 999 or 1000
Please do take note that, even when Horizontal Content Compression Resistance for UILabel is 999 or 1000, both red & green UIImageView
's width will be compressed. But, they are compressed with different strength, which end up 2 UIImageView
are having slightly different width. Why?
p/s
The complete project code is located at https://github.com/yccheok/stackoverflow/tree/master/66444344/test
UIImageView
is Aspect fit. - Cheok Yan Cheng