I just created a UIStackView programmatically. And there i added a button. But the frame of the button change its shape when I add it to the stackview. Look... Do you know how I can configure my stackview so that it doesn't change the frames of its members? My button used to be round
CodePudding user response:
Without seeing anything else about how you've set your constraints...
Your stack view properties should be:
Axis: Vertical
Alignment: Center
Distribution: Fill
Spacing: (whatever spacing value you need)
Then, to make your button "round" give it your desired Width constraint and a Height constraint equal to its own Width.
CodePudding user response:
you must add something in insepctor area in Xcode. [Distribution] - [Fill Equally]
if you want to create for programmatically...
lazy var stackView: UIStackView = {
let stackView = UIStackView()
stackView.distribution = .fillEqually
stackView.axis = .horizontal
stackView.alignment = .center
stackView.translatesAutoresizingMaskIntoConstraints = false
return stackView
}()