Skip to content

Instantly share code, notes, and snippets.

@BrettBukowski
Created October 31, 2012 02:16
Show Gist options
  • Save BrettBukowski/3984416 to your computer and use it in GitHub Desktop.
Save BrettBukowski/3984416 to your computer and use it in GitHub Desktop.
Apply mask for orientation change
// Apply a mask before rotating so that things aren't shifting around weirdly
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
CALayer *mask = [[CALayer alloc] init];
[mask setBounds:[[self view] bounds]];
[mask setContents:(__bridge id)[[UIColor darkGrayColor] CGColor]];
[[[self view] layer] setMask:mask];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
// Remove mask
[[[self view] layer] setMask:nil];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment