Home > Software design >  Custom distribution for UIStackView
Custom distribution for UIStackView

Time:02-05

I have the following UIStackView.

enter image description here

Here is the pseude-code:

let stack = UIStackView()
stack.axis = .vertical
stack.distribution = .fill

Blue, Yellow, Violet and Green views have their correct sizes (autosized labels or buttons). However, red one is being used to fill the remaining space.

I want that Violet one to fill the empty space instead of Red. Is there any way to specify which view should fill the empty space?

CodePudding user response:

You'll need to weight each view using contentHuggingPriority.

Try making the red view's contentHuggingPriority higher than the violet.

  •  Tags:  
  • Related