I\'m trying to add vertical lines, between labels inside a stack view all programatically.
The desired finish will be something like this image:
I c
I've upvoted @FrankByte.com's answer because he helped me get to my solution, which is pretty similar to what the OP wanted to do:
extension UIStackView {
func addVerticalSeparators(color : UIColor, multiplier: CGFloat = 0.5) {
var i = self.arrangedSubviews.count - 1
while i > 0 {
let separator = createSeparator(color: color)
insertArrangedSubview(separator, at: i)
separator.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: multiplier).isActive = true
i -= 1
}
}
private func createSeparator(color: UIColor) -> UIView {
let separator = UIView()
separator.widthAnchor.constraint(equalToConstant: 1).isActive = true
separator.backgroundColor = color
return separator
}
}