I am trying to find out PPI(Pixels Per Inch) in iOS.
I couldn't find any direct way to query this like we do for display size
UIScreen.mainScreen().bounds
There is a way to do it by multiplying scale with standard generic PPI for iPhone(163) or iPad(132) but it's not accurate.
If the formula is right then PPI of iPhone 6 plus is 489 but in reality the PPI is 401 Here is the reference
For now it seems like hardcoding is the way to go.
But I'd like to do it programmatically using a formula.
iPhone Plus has scale 3, but nativeScale is 2.6.
UIKit samples this content down to fit the actual screen dimensions. Metal or OpenGL ES contents should be rendered at the precise dimensions.
int screenPPI() {
return [[UIScreen mainScreen] nativeScale] * ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? 132 : 163);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With