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
@GOR answer extension only for vertical line and only in centers
Stackview settings: set width contraints of each subview and parent stackview should be fill
Here's a simple extension for adding vertical separators between each row.
func addVerticalSeparators(color : UIColor) {
var i = self.arrangedSubviews.count
while i > 1 {
let separator = verticalCreateSeparator(color: color)
insertArrangedSubview(separator, at: i-1) // (i-1) for centers only
separator.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: 1).isActive = true
i -= 1
}
}
private func verticalCreateSeparator(color : UIColor) -> UIView {
let separator = UIView()
separator.widthAnchor.constraint(equalToConstant: 1).isActive = true
separator.backgroundColor = color
return separator
}