Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status bar style support added #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LRScrollingSidebarController/LRScrollingSidebarController.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ typedef UIViewController<LRScrollingSidebarController> *ISSidePanelController;

@property (nonatomic) BOOL allowBouncing;
@property (nonatomic) BOOL allowParallax;
@property (nonatomic) UIStatusBarStyle statusbarStyle;
@property(nonatomic, getter=isStatusBarHidden) BOOL statusBarHidden;

@property (nonatomic, weak) id<LRScrollingSidebarControllerDelegate> delegate;

Expand Down
33 changes: 33 additions & 0 deletions LRScrollingSidebarController/LRScrollingSidebarController.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ - (void)loadView
[self buildUpMainHierarchy];
[self showInitialPanel];
[self activateScrollingSidebarNavigation];
[self updateStatusBarStyle];
}

- (void)showInitialPanel
Expand Down Expand Up @@ -306,6 +307,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView

[self applyParallaxEffect];
[self applyOverlayEffect];
[self updateStatusBarStyle];
}

- (void)applyParallaxEffect
Expand Down Expand Up @@ -415,4 +417,35 @@ - (NSUInteger)supportedInterfaceOrientations
return UIInterfaceOrientationMaskPortrait;
}

#pragma mark - status bar

// allows to use the child's StatusBar
- (UIViewController *)childViewControllerForStatusBarStyle
{
return [self visibleController];
}

- (UIViewController *)childViewControllerForStatusBarHidden
{
return [self visibleController];
}

- (void)updateStatusBarStyle
{
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
[self setNeedsStatusBarAppearanceUpdate];
}
}

// adjust the style of the base status bar while the app is running
- (UIStatusBarStyle)preferredStatusBarStyle
{
return self.statusbarStyle;
}

-(BOOL) prefersStatusBarHidden
{
return self.isStatusBarHidden;
}

@end
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ The category UIViewController+LRScrollingSidebarController aims at making every
```
[self.scrollingSidebarController showMainViewControllerAnimated:YES];
```
Additionally you can change or hide the initial status bar

```
@property (nonatomic) UIStatusBarStyle statusbarStyle;
@property(nonatomic, getter=isStatusBarHidden) BOOL statusBarHidden;
```
Or change it or hide it individually from each of your child controllers by adding one of these two methods

```
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}

-(BOOL) prefersStatusBarHidden {
return YES;
}
```
Note: we are assuming that your "View controller-based status bar appearance" in your info.plist is set to YES

### Requirements

Expand Down