Last active
March 18, 2018 13:15
Revisions
-
serpent7776 revised this gist
Mar 18, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -24,6 +24,6 @@ - (CGFloat)pointsToPixels:(CGFloat)points { } else { pixelPerInch = 160 * scale; } CGFloat px = points / pointsPerInch * pixelPerInch; return px; } -
danielcardeenas created this gist
Apr 1, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ - (CGFloat)pixelToPoints:(CGFloat)px { CGFloat pointsPerInch = 72.0; // see: http://en.wikipedia.org/wiki/Point%5Fsize#Current%5FDTP%5Fpoint%5Fsystem CGFloat scale = 1; float pixelPerInch; // DPI if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { pixelPerInch = 132 * scale; } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { pixelPerInch = 163 * scale; } else { pixelPerInch = 160 * scale; } CGFloat points = px * pointsPerInch / pixelPerInch; return points; } - (CGFloat)pointsToPixels:(CGFloat)points { CGFloat pointsPerInch = 72.0; // see: http://en.wikipedia.org/wiki/Point%5Fsize#Current%5FDTP%5Fpoint%5Fsystem CGFloat scale = 1; float pixelPerInch; // DPI if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { pixelPerInch = 132 * scale; } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { pixelPerInch = 163 * scale; } else { pixelPerInch = 160 * scale; } CGFloat px = points / (pointsPerInch * pixelPerInch); return px; }