JASidePanels icon indicating copy to clipboard operation
JASidePanels copied to clipboard

Added possibility to respond to when the sidepanels move/pan

Open filipengberg opened this issue 11 years ago • 4 comments

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

filipengberg avatar Oct 09 '13 15:10 filipengberg

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

AppyPt avatar Oct 14 '13 18:10 AppyPt

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;
        }];
    }
}

filipengberg avatar Oct 15 '13 08:10 filipengberg

worked like a charm. Many thanks.

AppyPt avatar Oct 15 '13 10:10 AppyPt

+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.

ijansch avatar Feb 26 '14 07:02 ijansch