Created
May 12, 2020 02:42
-
-
Save codelynx/0859605c42d6595a3529c18a5f4da2f8 to your computer and use it in GitHub Desktop.
extension of UnitLength (Measurement) to support Points
This file contains hidden or 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
import Foundation | |
extension UnitLength { | |
static let points = UnitLength(symbol: "pt", converter: UnitConverterLinear(coefficient: 0.0003527778, constant: 0)) | |
} | |
let inches = Measurement(value: 1, unit: UnitLength.inches) // 1.0 in | |
let points = inches.converted(to: UnitLength.points) // 71.99999546456722 pt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment