使用自动布局减少文本字段周围的 space

Reduce space around a textfield using auto layout

我目前使用的是包含一些垂直对齐元素的 stackView。我在代码中做所有事情。

我已经标记了每个堆栈视图的子视图。这是屏幕截图:

这是堆栈视图的代码:

func setUpVerticalLayoutStackView() {
    stackViewForVerticalLayout = UIStackView(arrangedSubviews: [viewTitleButton, stackViewForTheTwoPersons, owedButton, amountTextField, doneButton])
    stackViewForVerticalLayout.axis = .vertical
    stackViewForVerticalLayout.distribution = .equalCentering
    stackViewForVerticalLayout.alignment = .center
    stackViewForVerticalLayout.spacing = 20
    stackViewForVerticalLayout.translatesAutoresizingMaskIntoConstraints = false
    self.addSubview(stackViewForVerticalLayout)
}

我的问题是:为什么文本框占那么多space?我可以通过某种方式减少它吗?

不要介意视图中心的 "r",这只是我在图像编辑器中错误添加的东西。

根据需要将stackViewForVerticalLayout.distribution更改为.equalSpacing.fillEqually。这将减少该字段的大小