Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically Set Spacing on Stackview

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!

like image 582
SF Dev Avatar asked Nov 19 '16 22:11

SF Dev


2 Answers

let stackView = UIStackView()
stackView.spacing = 10.0      // or whatever you like
like image 91
Wes Avatar answered Nov 18 '22 23:11

Wes


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
  }
}
like image 3
Braham Youssef Avatar answered Nov 18 '22 23:11

Braham Youssef