Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunogama/c44cfee50e88cda9b2a6ddbb67529dad to your computer and use it in GitHub Desktop.
Save brunogama/c44cfee50e88cda9b2a6ddbb67529dad to your computer and use it in GitHub Desktop.
UIStackView SpacerView
/**! 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