Toma Radu-Petrescu
Toma Radu-Petrescu

Reputation: 2262

Label inside Stack View

I am trying to have this format inside my cells, but I can't figure out what I should do in order to stop errors from appearing. My guess is that the problem is that the text labels have intrinsic size? If I would only have, let's say, the Name label, I would have a warning which would say that it was expected a higher height for the label. Can you please shed some light on these problems?

Upvotes: 0

Views: 2360

Answers (1)

ldindu
ldindu

Reputation: 4380

You appeared to be having issues with Compression resistance and content hugging priority. A view with high compression resistance will fight against shrinking and in other words, it will prevent the content to clip.

Content hugging, on the other hand, limits the view from growing larger than its content.

You need to set labels compression resistance and content hugging priority accordingly. Set higher compression resistance value, max is 1000, for the view which you don't want to shrink and set others value < 1000 for other views.

In order to satisfy auto resizing requirement resulted from different screen sizes, you need to ensure that content hugging property is appropriately set for views. Some views can grow to satisfy the constraint requirements. Set higher content priority for the view which you want it to prevent from overgrowing than its content size.

Upvotes: 2

Related Questions