Open AdityaSethi opened 10 years ago
It's faily easy to do it, though. Do this in the frontViewController
overlay = [[UIView alloc] initWithFrame:self.view.frame];
[overlay setHidden:YES];
[overlay setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:ALPHA_FRONTVC_OVERLAY]];
[self.view addSubview:overlay];
self.revealController.delegate = self;
Since, now, your ViewController gets all the events from the PKRevealing protocol, you do this:
- (void)revealController:(PKRevealController *)revealController willChangeToState:(PKRevealControllerState)state{
if(state == PKRevealControllerShowsFrontViewController){
[overlay setAlpha:ALPHA_FRONTVC_OVERLAY];
[UIView animateWithDuration:.5 animations:^{
overlay.alpha = 0;
} completion:^(BOOL finished) {
[overlay setHidden:YES];
}];
}else if(state == PKRevealControllerShowsLeftViewController){
[overlay setAlpha:0];
[overlay setHidden:NO];
[UIView animateWithDuration:.5 animations:^{
[overlay setAlpha:ALPHA_FRONTVC_OVERLAY];
}];
}
}
Where ALPHA_FRONTVC_OVERLAY
is how dark you want the FrontViewController to get.
Nicely done. IMO, I found making the animation to overlay same as the PKReve.. animationDuration cool.
Thanks for the code!
+1. Issue almost one yr old. I guess that's a no.