Backelite/MaryPopin

Blur navigation controller background

Closed this issue · 10 comments

I have MaryPopin working with a basic navigation controller, however I can't achieve a blur affect on the background. Is there a way to achieve this, I have as follows...

 BKTPopinControllerViewController *popin = [[BKTPopinControllerViewController alloc] init];
    [popin setPopinTransitionStyle:[self transitionStyleForIndexPath:selectedIndexPath]];


    if ([self isDismissable]) {
        [popin setPopinOptions:BKTPopinDefault];
    } else {
        [popin setPopinOptions:BKTPopinDisableAutoDismiss];
    }

    //Set popin alignement according to value in segmented control
    [popin setPopinAlignment:self.selectedAlignementOption];

    //Create a blur parameters object to configure background blur
    BKTBlurParameters *blurParameters = [BKTBlurParameters new];
    blurParameters.alpha = 1.0f;
    blurParameters.radius = 8.0f;
    blurParameters.saturationDeltaFactor = 1.8f;
    blurParameters.tintColor = [UIColor colorWithRed:0.966 green:0.851 blue:0.038 alpha:0.2];
    [popin setBlurParameters:blurParameters];

    //Add option for a blurry background
    [popin setPopinOptions:[popin popinOptions]|BKTPopinBlurryDimmingView];

    [popin setPreferedPopinContentSize:CGSizeMake(280.0, 240.0)];

    //Set popin transition direction
    [popin setPopinTransitionDirection:BKTPopinTransitionDirectionTop];

    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:popin];

    [self presentPopinController:nav animated:YES completion:^{
        NSLog(@"Popin presented !");
    }];

Popin options should be set on the controller presented as a popin, which is the UINavigationController in your case. Try setting all your options on navinstead of popin and it should work as expected.

Hi, thanks so much for your reply.

However, now, my parent view moves to the top left position, I get a black area on the left and at the top, I mean I do get the dialog too.
The gap changes depending on the size passed in from setPreferedPopinContentSize.
I'm not sure what's happening, any further suggestions?

When using a simple UIViewController the popin use its size unless a preferedPopinContentSize is set. With a UINavigationController it is a little different because it does not have a size, it is just a container for other view controllers. So using setPreferedPopinContentSize allows to set the desired size. I think it is why the gap changes depending on the size. For the gap itself, maybe it is related to your autoresizing masks or auto layout constraints ?

Ahhh thanks, I had some code to resize as I wanted to make the dialog a different size and this was somehow adjusting the parent too. Just need to figure how to dismissing the popup.

I thought this would have worked, hmmm

    [self dismissCurrentPopinControllerAnimated:YES completion:^{
        NSLog(@"Popin dismissed !");
        [self.navigationController popViewControllerAnimated:YES];

    }];

Well, if self is the controller presenting the popin it should work but if it is the popin controller, you'll have to use:

[self.presentingPopinViewController dismissCurrentPopinControllerAnimated:YES completion:^{
        NSLog(@"Popin dismissed !");
        [self.navigationController popViewControllerAnimated:YES];

    }];

Thanks for your efforts, but that doesn't work, I've also tried adding the popup to self instead of navigation controller, but that doesn't help either.

Any further suggestions?

    [self presentPopinController:popin animated:YES completion:^{
        NSLog(@"Popin presented !");
    }];

I've created an example project, would you please have a look?

https://github.com/Jules2010/PopupTest

Thanks for your help.

I had a quick look to your sample project. Change the code to dismiss the popin with:

[self.navigationController.presentingPopinViewController dismissCurrentPopinControllerAnimated:YES completion:^{
        NSLog(@"Popin dismissed !");
        [self.navigationController popViewControllerAnimated:YES];
 }];

Thanks so much, that solves it. :)

Now if I could fade instead of slide, that would be awesome, I guess I can make do with cross-fade or turn off animation though.

Thanks for all your help :)