JASidePanels
JASidePanels copied to clipboard
Added possibility to respond to when the sidepanels move/pan
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
reekris: did you already implement the status bar effect on IOS 7, with that method? Can you share the code? tks
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;
}];
}
}
worked like a charm. Many thanks.
+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.