Skip to content

Instantly share code, notes, and snippets.

@bjhomer
Last active September 5, 2017 16:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjhomer/340f569de8e50734fe3b6a6ecc0ae7d1 to your computer and use it in GitHub Desktop.
Save bjhomer/340f569de8e50734fe3b6a6ecc0ae7d1 to your computer and use it in GitHub Desktop.
public extension NSLayoutConstraint.Priority {
public static func -(lhs: NSLayoutConstraint.Priority, rhs: Float) -> NSLayoutConstraint.Priority {
return NSLayoutConstraint.Priority(lhs.rawValue - rhs)
}
public static func +(lhs: NSLayoutConstraint.Priority, rhs: Float) -> NSLayoutConstraint.Priority {
return NSLayoutConstraint.Priority(lhs.rawValue + rhs)
}
}
let constraint = // Some NSLayoutConstraint object.
constraint.priority = .required - 1 // Now you can do this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment