Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save EchoAbstract/d781e3189d8025410368 to your computer and use it in GitHub Desktop.
Save EchoAbstract/d781e3189d8025410368 to your computer and use it in GitHub Desktop.
@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