3

enter image description here

The NSStackView shown above has top/leading/trailing constraints, a proportional height to its superview, and is set to Align Top and Fill Equally. I want to have the buttons stretch vertically to fill the height of their stack view. How can I configure this with a NSStackView? Or do I have to add constraints on the buttons?

Fogmeister
  • 76,236
  • 42
  • 207
  • 306
elce
  • 264
  • 4
  • 16

2 Answers2

2

I solved my problem by setting top/bottom constraints on the buttons to the stack view. I don't think there is a way to configure an NSStackView to do what I want.

So a UIButton fills the height of the UIStackView if the UIStackView's alignment is set to fill. An NSStackView does not have a fill property for alignment and AFAIK, can't make an NSButton do the same thing

elce
  • 264
  • 4
  • 16
1

As you already noticed, it's not possible using NSStackView. It lacks fill alignment, available for UIStackView.

However, there is a much more powerful UI component in AppKit:

NSGridView - https://developer.apple.com/documentation/appkit/nsgridview

You can customize alignment for each row and column, including "fill" mode.

Darrarski
  • 3,882
  • 6
  • 37
  • 59