Skip to content

Instantly share code, notes, and snippets.

@EvgenyMorozov
Created August 7, 2015 08:59
Show Gist options
  • Save EvgenyMorozov/85d0eab01cd4921ffff1 to your computer and use it in GitHub Desktop.
Save EvgenyMorozov/85d0eab01cd4921ffff1 to your computer and use it in GitHub Desktop.
Hide/show status bar on sidebar opening (SWRevealViewController)
- (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position
{
if (position == FrontViewPositionRight) {
UIApplication *sharedApplication = [UIApplication sharedApplication];
CGFloat statusBarHeight = CGRectGetHeight([sharedApplication statusBarFrame]);
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
UINavigationController *frontViewController = (id)revealController.frontViewController;
CGPoint center = frontViewController.navigationBar.center;
center.y += statusBarHeight;
frontViewController.navigationBar.center = center;
UIViewController *topViewController = frontViewController.topViewController;
topViewController.view.frame = CGRectOffset(topViewController.view.frame, 0, statusBarHeight);
}
else {
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
}
}
@munibrahman
Copy link

Pardon my ignorance, but which file would you add this in? Specifically, which view controller? Thanks

@rp2701
Copy link

rp2701 commented Mar 17, 2017

The class that implements the SWRevealViewControllerDelegate protocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment