Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeremiegirault/7f73692a162b6ecf8ef60c7809e8679e to your computer and use it in GitHub Desktop.
Save jeremiegirault/7f73692a162b6ecf8ef60c7809e8679e to your computer and use it in GitHub Desktop.
Helpers for UILayoutPriority for swift 4
extension UILayoutPriority: ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral {
public init(floatLiteral value: Float) {
self.init(rawValue: value)
}
public init(integerLiteral value: Int) {
self.init(rawValue: Float(value))
}
public static func +(lhs: UILayoutPriority, rhs: UILayoutPriority) -> UILayoutPriority {
return UILayoutPriority(rawValue: lhs.rawValue + rhs.rawValue)
}
public static func -(lhs: UILayoutPriority, rhs: UILayoutPriority) -> UILayoutPriority {
return UILayoutPriority(rawValue: lhs.rawValue - rhs.rawValue)
}
}
let view = UIView()
view.setContentCompressionResistancePriority(.defaultHigh + 1, for: .horizontal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment