How to get screen size using code on iOS?

You can use the bounds property on an instance of UIScreen:

CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;  
CGFloat screenWidth = screenSize.width;
CGFloat screenHeight = screenSize.height;

Most people will want the main screen; if you have a device attached to a TV, you may instead want to iterate over UIScreens and get the bounds for each.

More info at the UIScreen class docs.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)