Created
April 20, 2017 08:55
-
-
Save brunojppb/3603f09f5bda63d2ffb196e85213d521 to your computer and use it in GitHub Desktop.
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
import UIKit | |
extension CGFloat { | |
/** Targeting the Photo Book API, converts pixels to points */ | |
var pixelToPoints: CGFloat { | |
let pointsPerInch: CGFloat = 72 | |
let scale: CGFloat = UIScreen.main.scale | |
let pixelPerInch: CGFloat | |
if UIDevice.current.userInterfaceIdiom == .pad { | |
pixelPerInch = 132 * scale | |
} else if UIDevice.current.userInterfaceIdiom == .phone { | |
pixelPerInch = 163 * scale | |
} else { | |
pixelPerInch = 160 * scale | |
} | |
return self * pointsPerInch / pixelPerInch | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment