pprevalon pprevalon - 7 months ago 40
Swift Question

Swift how to increase margins of arranged views

How can Increase the the margin of different

inside a
. I need to increase the the top margin the margins will be the same.

let formWrapperStackView:UIStackView = {
let v = UIStackView()
v.axis = .vertical
// v.distribution = .fillProportionally
v.spacing = 0
v.translatesAutoresizingMaskIntoConstraints = false

return v

enter image description here


It is not possible to have different spacing for different elements in a UIStackView. So a solution would be to wrap each of your textfields with a UIView and then set the top constraint of each textfield (between textfield and UIView) to your desired margin.