Skip to content

Instantly share code, notes, and snippets.

@ZhukV
Created April 22, 2015 11:26
Show Gist options
  • Save ZhukV/4d621bb0332770aa6a8a to your computer and use it in GitHub Desktop.
Save ZhukV/4d621bb0332770aa6a8a to your computer and use it in GitHub Desktop.
#import "UIScreen+ScreenBounds.h"
@implementation UIScreen (ScreenBounds)
+ (CGRect)screenBounds
{
CGRect screenBounds = [UIScreen mainScreen].bounds;
if(NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1){
return screenBounds;
}
CGFloat width = CGRectGetWidth(screenBounds);
CGFloat height = CGRectGetHeight(screenBounds);
UIInterfaceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
if(UIInterfaceOrientationIsPortrait(interfaceOrientation)){
screenBounds.size = CGSizeMake(width, height);
}else if(UIInterfaceOrientationIsLandscape(interfaceOrientation)){
screenBounds.size = CGSizeMake(height, width);
}
return screenBounds;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment