Skip to content

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

Open
filipengberg wants to merge 1 commit intogotosleep:masterfrom
filipengberg:pancallback
Open

Added possibility to respond to when the sidepanels move/pan#173
filipengberg wants to merge 1 commit intogotosleep:masterfrom
filipengberg:pancallback

Conversation

@filipengberg
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown

AppyPt commented Oct 15, 2013

worked like a charm. Many thanks.

@ijansch
Copy link
Copy Markdown

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