Jun 5, 2014

[iOS] Get the screen width and height

If you need the screen size, you should look at the object that represents the screen itself, like this:
CGRect screenRect = [[UIScreen mainScreen] bounds];CGFloat screenWidth = screenRect.size.width;CGFloat screenHeight = screenRect.size.height;
Or
+ (CGFloat) window_height   {
    return [UIScreen mainScreen].applicationFrame.size.height;
}
+ (CGFloat) window_width   {
    return [UIScreen mainScreen].applicationFrame.size.width;

No comments:

Post a Comment