Skip to content

Instantly share code, notes, and snippets.

@codelynx
Created May 12, 2020 02:42
Show Gist options
  • Save codelynx/0859605c42d6595a3529c18a5f4da2f8 to your computer and use it in GitHub Desktop.
Save codelynx/0859605c42d6595a3529c18a5f4da2f8 to your computer and use it in GitHub Desktop.
extension of UnitLength (Measurement) to support Points
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