You will need to set an explicit constraint to make tableView.height 4x bigger than your view size. They don't have intrinsic content size, so the stackView
does not "know" how to properly fill the space.
Also, set the distribution mode to .fill
, because .fillProportionally
uses intrinsic content size to determine proper distribution (excerpt from docs):
case fillProportionally
A layout where the stack view resizes its arranged views so that they fill the available space along the stack view’s axis. Views are resized proportionally based on their intrinsic content size along the stack view’s axis.
Using constraints we are setting the size explicitly, not using intrinsic content size - thus .fillProportionally
does not work. I assume in that case the stackView
uses values returned by view.intrinsicContentSize
directly. However, constraints will not change view.intrinsicContentSize
.
If you would be doing it in code, you could do it with this:
tableView.heightAnchor.constraint(equalTo: myView.heightAnchor, multiplier: 4).isActive = true
In storyboards, control drag from tableView
to the myView
and select Equal Heights
:
Then select the created constraint and set the appropriate multiplier: