将底部的相等 UIViews 与固定高度对齐

Align equal UIViews on the bottom with fixed height

我一直在努力实现类似于下面示例的东西,但现在还没有成功。

这是我目前的情况:

H:|[firstView][secondView(== firstView)][thirdView(== firstView)][fourthView(== firstView)]|

这有效,但是,它产生了这个结果:

我试图让它看起来像这样:

换句话说,我试图在屏幕底部放置 4 个等宽和固定高度的 UIView。

有人对视觉格式限制有任何意见或参考吗?

我不太确定如何在一个约束中执行多个视图,但这是一次一个视图的方法。

这会做你的左右约束:

NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[V]-0-|", options: [], metrics: nil, views: ["V" : firstview]))

这会将视图限制在屏幕底部:

NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:[V]-0-|", options: [], metrics: nil, views: ["V" : firstview]))

然后添加高度限制:

NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[V(25)]|", options: [], metrics: nil, views: ["V" : firstview]))