
ios 에서 pixel to point , point to pixel 로 변환하는 방법
+ (CGFloat)pixelToPoints:(CGFloat)px
{
CGFloat pointsPerInch = 72.0;
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:(float)point
{
float pixel; //ipad
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ){
pixel = point / 0.54545455;
}else{
//iphone
pixel = point / 0.44171789;
}
return pixel;
}
Leave ios 에서 pixel to point , point to pixel 로 변환하는 방법 to:
Read more #kr posts
Best Posts From esjung
We have not curated any of esjung's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.