iOS get physical screen size programmatically?

前端 未结 11 1944
情话喂你
情话喂你 2020-12-15 03:11

Is this possible? I want the number of inches, not the number of pixels. I know it is approximately 160 ppi. But not exactly.

11条回答
  •  别那么骄傲
    2020-12-15 03:53

    CGFloat scale = [UIScreen mainScreen].scale; CGRect screenRect = [[UIScreen mainScreen] bounds]; CGFloat screenWidth = screenRect.size.width * (scale/100.0f); CGFloat screenHeight = screenRect.size.height * (scale/100.0f);

    • scale is persent!

提交回复
热议问题