Skip to content

Instantly share code, notes, and snippets.

@sdpjswl
Last active August 29, 2015 14:06
Show Gist options
  • Save sdpjswl/e250cc148af4faed746e to your computer and use it in GitHub Desktop.
Save sdpjswl/e250cc148af4faed746e to your computer and use it in GitHub Desktop.
Get screen size depending on device orientation
//
// UIApplication+AppDimensions.m
// GolfByJordan
//
// Created by sudeep on 26/08/14.
// Copyright (c) 2014 Esense. All rights reserved.
//
#import "UIApplication+AppDimensions.h"
@implementation UIApplication (AppDimensions)
+(CGSize)currentSize;
@end
//
// UIApplication+AppDimensions.m
// GolfByJordan
//
// Created by sudeep on 26/08/14.
// Copyright (c) 2014 Esense. All rights reserved.
//
#import "UIApplication+AppDimensions.h"
@implementation UIApplication (AppDimensions)
+(CGSize) currentSize {
return [UIApplication sizeInOrientation:[UIApplication sharedApplication].statusBarOrientation];
}
+(CGSize) sizeInOrientation:(UIInterfaceOrientation)orientation {
CGSize size = [UIScreen mainScreen].bounds.size;
if (UIInterfaceOrientationIsLandscape(orientation)) {
CGFloat version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version < 8.0) {
size = CGSizeMake(size.height, size.width);
}
else {
size = CGSizeMake(size.width, size.height);
}
}
return size;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment