Programmatically set interval in stackview

As the name says, I searched around, but no luck. Is it possible to connect the stack view to a .swift file and then adjust the interval programmatically? Thank!

+4
source share
2 answers
let stackView = UIStackView()
stackView.spacing = 10.0      // or whatever you like
+6
source

If 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
  }
}
+2
source

Source: https://habr.com/ru/post/1661313/


All Articles