8

Like the title says, I have searched around but had no luck. Is it possible to connect the stack view to the .swift file and then adjust the spacing programmatically? Thank you!

SF Dev
  • 389
  • 1
  • 3
  • 13

2 Answers2

19
let stackView = UIStackView()
stackView.spacing = 10.0      // or whatever you like
Wes
  • 1,032
  • 7
  • 11
3

In case you have a custom UIStackView

class YourCustomSublcass {
  //MARK: Initialization of the stackView
  override init(frame: CGRect) {
    super.init(frame: frame)
    self.spacing = 8.0
  }

  required init(coder :NSCoder){
    super.init(coder: coder)
    self.spacing = 8.0
  }
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Braham Youssef
  • 479
  • 6
  • 6