mutualmobile / MMDrawerController

A lightweight, easy to use, Side Drawer Navigation Controller
MIT License
6.76k stars 1.38k forks source link

percentVisible jump to 0 or 1 when my finger left screen #473

Open iTofu opened 7 years ago

iTofu commented 7 years ago

I want to dim the centerController view while drawer is open in MMDrawerController with gradient effect, I do this:

    UIView *blurView = [[UIView alloc] init];
    blurView.backgroundColor = [UIColor blackColor];
    [self.drawerController setDrawerVisualStateBlock:^(MMDrawerController *drawerController, MMDrawerSide drawerSide, CGFloat percentVisible) {

        NSLog(@"%f", percentVisible);

        blurView.alpha  = 0.5f * percentVisible;
        if (percentVisible > 0 && !blurView.superview) {
            [drawerController.centerViewController.view addSubview:blurView];
            [blurView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.equalTo(drawerController.centerViewController.view);
            }];
        }
        if (percentVisible == 0) {
            [blurView removeFromSuperview];
        }
    }];

But I found percentVisible just jump to 0 or 1 if my finger left screen, not like: 0.50 -> 0.49 -> 0.48 ... -> 0.01 - 0?

iTofu commented 7 years ago

Any advise?