Created
June 11, 2017 19:03
-
-
Save jeremiegirault/7f73692a162b6ecf8ef60c7809e8679e to your computer and use it in GitHub Desktop.
Helpers for UILayoutPriority for swift 4
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
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