Skip to content

Instantly share code, notes, and snippets.

@steventroughtonsmith
Created August 30, 2014 12:13
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save steventroughtonsmith/96da8fe10ecd70d104bc to your computer and use it in GitHub Desktop.
Save steventroughtonsmith/96da8fe10ecd70d104bc to your computer and use it in GitHub Desktop.
UICustomResolutions
@interface UIWindow (resize)
-(void)_adjustSizeClassesAndResizeWindowToFrame:(CGRect)frame;
@end
typedef enum _UICustomRes
{
UICustomResiPadTwoThirds,
UICustomResiPadHalf,
UICustomResiPadOneThird,
UICustomResiPhone47,
UICustomResiPhone55,
UICustomResNone
} UICustomRes;
UICustomRes _forceResizeState = UICustomResNone;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UITapGestureRecognizer *resizeTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_forceResize:)];
resizeTapGesture.numberOfTouchesRequired = 3;
[self.window addGestureRecognizer:resizeTapGesture];
return YES;
}
-(void)_forceResize:(UITapGestureRecognizer *)sender
{
switch (_forceResizeState)
{
case UICustomResiPadTwoThirds:
[self.window _adjustSizeClassesAndResizeWindowToFrame:CGRectMake(0, 0, 704, 768)];
break;
case UICustomResiPadHalf:
[self.window _adjustSizeClassesAndResizeWindowToFrame:CGRectMake(0, 0, 512, 768)];
break;
case UICustomResiPadOneThird:
[self.window _adjustSizeClassesAndResizeWindowToFrame:CGRectMake(0, 0, 320, 768)];
break;
case UICustomResiPhone47:
[self.window _adjustSizeClassesAndResizeWindowToFrame:CGRectMake(0, 0, 375, 667)];
break;
case UICustomResiPhone55:
[self.window _adjustSizeClassesAndResizeWindowToFrame:CGRectMake(0, 0, 414, 736)];
break;
case UICustomResNone:
[self.window _adjustSizeClassesAndResizeWindowToFrame:CGRectMake(0, 0, 1024, 768)];
break;
default:
break;
}
_forceResizeState++;
if (_forceResizeState > UICustomResNone)
_forceResizeState = UICustomResiPadTwoThirds;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment