Last active
September 15, 2021 21:35
-
-
Save DanielCardonaRojas/a59628b274f138113df6b7213de89277 to your computer and use it in GitHub Desktop.
UIStackView+Extensions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIStackView { | |
func insertSeparator(_ createSeparator: (() -> UIView)) { | |
let subviews = self.arrangedSubviews | |
for v in subviews { | |
self.removeArrangedSubview(v) | |
} | |
for v in subviews { | |
self.addArrangedSubview(v) | |
self.addArrangedSubview(createSeparator()) | |
} | |
} | |
func separator(color: UIColor, size: CGFloat) { | |
self.insertSeparator { () -> UIView in | |
let separator = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 200, height: 5.0))) | |
separator.heightAnchor.constraint(equalToConstant: 2.0).isActive = true | |
separator.widthAnchor.constraint(equalToConstant: 200).isActive = true | |
separator.backgroundColor = color | |
return separator | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment