IOS - how do I find the screen size of the user's device?

0

I would like to know if there is a way to find out the size of the screen that the user is using or the model of your iPhone via Objectice-C.

    
asked by anonymous 28.03.2016 / 20:01

1 answer

1

To find the screen size in points , you can use the bounds method:

CGRect screenBounds = [[UIScreen mainScreen] bounds];

If you want to know the screen size in pixels , you need to figure out the scale of the screen. For example, older phones will have a 1.0 scale, retina 2.0, and larger ones (e.g. iPhone 6 Plus) 3.0.

CGFloat screenScale = [[UIScreen mainScreen] scale];

And then convert from points to pixels :

CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);

Font (from SOen) .

    
28.03.2016 / 20:07