Forked from steventroughtonsmith/gist:96da8fe10ecd70d104bc
Last active
August 29, 2015 14:06
-
-
Save EchoAbstract/d781e3189d8025410368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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