Skip to content
This repository has been archived by the owner on Sep 11, 2022. It is now read-only.

Does it support a dim overlay on the fronViewController when the right/left controllers are focused ? #208

Open
AdityaSethi opened this issue Jul 17, 2014 · 4 comments

Comments

@AdityaSethi
Copy link

No description provided.

@pbassut
Copy link

pbassut commented Apr 26, 2015

+1. Issue almost one yr old. I guess that's a no.

@pbassut
Copy link

pbassut commented Apr 26, 2015

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.

@kokuneye
Copy link

Nicely done.
IMO, I found making the animation to overlay same as the PKReve.. animationDuration cool.

@BorisNikolic
Copy link

Thanks for the code!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants