Created
February 18, 2022 17:36
-
-
Save dornad/6b8b466f2a1e1eeaaa5205c0e102b5b4 to your computer and use it in GitHub Desktop.
UIStackView SpacerView
This file contains 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
/**! Currently these two cause this warning: | |
This NSLayoutConstraint is being configured with a constant that exceeds internal limits. | |
A smaller value will be substituted, but this problem should be fixed. | |
Break on BOOL _NSLayoutConstraintNumberExceedsLimit(void) to debug. This will be logged only once. | |
This may break in the future. | |
*/ | |
extension UIStackView { | |
/// A vertical spacer view that will expand to fill the available space | |
fileprivate func verticalSpacer() -> UIView { | |
let v = UIView() | |
v.translatesAutoresizingMaskIntoConstraints = false | |
let constraint = v.heightAnchor.constraint(equalToConstant: .greatestFiniteMagnitude) | |
constraint.priority = .defaultLow | |
constraint.isActive = true | |
return v | |
} | |
/// A horizontal spacer view that will expand to fill the available space | |
fileprivate func horizontalSpacer() -> UIView { | |
let v = UIView() | |
v.translatesAutoresizingMaskIntoConstraints = false | |
let constraint = v.widthAnchor.constraint(equalToConstant: .greatestFiniteMagnitude) | |
constraint.priority = .defaultLow | |
constraint.isActive = true | |
return v | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment