Skip to content

Instantly share code, notes, and snippets.

@mehmetf
Created August 17, 2017 15:07
Show Gist options
  • Save mehmetf/f963c74770925045be5ee01ce186012a to your computer and use it in GitHub Desktop.
Save mehmetf/f963c74770925045be5ee01ce186012a to your computer and use it in GitHub Desktop.
secure window with color
- (void)applicationWillResignActive:(UIApplication *)application {
UIView *__autoreleasing colorView =
[[UIView alloc] initWithFrame:self.window.frame];
// Can be any integer you’re not using as a tag.
colorView.tag = 9999;
// Here we used white as the subview color.
colorView.backgroundColor = [UIColor whiteColor];
[self.window addSubview:colorView];
[self.window bringSubviewToFront:colorView];
}
— (void)applicationDidBecomeActive:(UIApplication *)application {
UIView *colorView = [self.window viewWithTag:9999];
[colorView removeFromSuperview];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment