Programmatically Set Spacing on Stackview
Asked Answered
N

2

9

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!

Nevermore answered 19/11, 2016 at 22:28 Comment(0)
D
19
let stackView = UIStackView()
stackView.spacing = 10.0      // or whatever you like
Diggins answered 19/11, 2016 at 22:32 Comment(0)
K
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
  }
}
Kirima answered 18/1, 2018 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.