robb / Cartography

A declarative Auto Layout DSL for Swift :iphone::triangular_ruler:
Other
7.35k stars 525 forks source link

Add an overload to the priority operator ('~') that accepts a float. #271

Closed philippelatulippe closed 6 years ago

philippelatulippe commented 6 years ago

In Swift 4, UILayoutPriority is a RawRepresentable instead of a Float, so passing numbers to the priority ~ operator no longer works out of the box.

This patch adds a function that takes a Float for the priority, and creates a UILayoutPriority from it. With this change, the Cartography DSL will stay compatible from Swift 3 to Swift 4.

Fixes the issue I opened here: #270

orta commented 6 years ago

I want to get this merged and in 3.0, so I'm happy for the slight duplication