First off, do you really need a stack view? It would be much easier to organize this simply by using direct height limits.
However, you can do this with the stack view if you really want to use the stack view. The secret is that the "weight" in question is simply an ordered view of intrinsicContentSize().height . Knowing this, I could easily create a stack view consisting of three images in the requested proportions:

Those for demonstration purposes are the same image repeated three times: one at a height of 3x, one at a height of 6x and one at a height of 1x.
How did i do this? I gave three images tag values ββof 300, 600 and 100 respectively in the storyboard. (Of course, I could use the individual IBInspectable property for this, and in real life I would.) Then I made all the instances of my subclass of UIImageView MyImageView, whose code looks like this:
class MyImageView: UIImageView { override func intrinsicContentSize() -> CGSize { print(self.tag) return CGSizeMake(CGFloat(self.tag), CGFloat(self.tag)) } }
The stack view distribution is configured as padding proportionally. Representations of images are adjusted using the content mode as bars for filling. Result: the presentation of the stack when building its ordered views accesses the intrinsicContentSize method and, thus, does the right thing.
source share