Coding, How-To

iOS: Getting Screen Size

To obtain the screen size based on the orientation and type of device, use this:

CGRect screenFrame = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenFrame.size.width;
CGFloat screenHeight = screenFrame.size.height;

screenWidth will return the width, and screenHeight, the height of your screen, even when your device is in the landscape orientation.



Leave a Reply

Your email address will not be published. Required fields are marked *