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

Added possibility to respond to when the sidepanels move/pan #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

filipengberg
Copy link

Added public method:
- (void)willPanToSidePanelVisiblePercent:(CGFloat)percent duration:(CGFloat)duration

This method gets called whenever the sidepanels moves.
Overriding this method in your JASidePanelController subclass allows you to respond to pan changes with fine grained control.
I needed this to be able to fade the background of the status bar to opaque black in iOS7 when the centerPanel gets panned to either side (Like Facebook does on iOS7)

Video for clarity: http://youtu.be/5T2YV_hl7S0

@AppyPt
Copy link

AppyPt commented Oct 14, 2013

reekris: did you already implement the status bar effect on IOS 7, with that method? Can you share the code? tks

@filipengberg
Copy link
Author

Sure!

In my JASidePanelController subclass I have added the following properties

@property (nonatomic, retain) UIView *statusbarBackgroundView;
@property (nonatomic, assign) BOOL shouldFadeStatusBarBackground;

in viewDidLoad I check for iOS7 and if it is, I init the background and set its alpha to 0:

self.shouldFadeStatusBarBackground = ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) ? YES : NO;
if(self.shouldFadeStatusBarBackground) {
    self.statusbarBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 20)];
    self.statusbarBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    self.statusbarBackgroundView.backgroundColor = [UIColor blackColor];
    self.statusbarBackgroundView.alpha = 0.0f;
    [self.view addSubview:self.statusbarBackgroundView];
}

To change the alpha on pan changes, I override willPanToSidePanelVisiblePercent like this:

- (void)willPanToSidePanelVisiblePercent:(CGFloat)percent duration:(CGFloat)duration {
    if(self.shouldFadeStatusBarBackground) {
        [UIView animateWithDuration:duration animations:^{
            self.statusbarBackgroundView.alpha = percent;
        }];
    }
}

@AppyPt
Copy link

AppyPt commented Oct 15, 2013

worked like a charm. Many thanks.

@ijansch
Copy link

ijansch commented Feb 26, 2014

+1 for this pull request, we needed it to create a facebook style way of handling the statusbar fade since the menu and main screen backgrounds have a different color.

robmaceachern added a commit to robmaceachern/JASidePanels that referenced this pull request Dec 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants