+ (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;
}