SWRevealViewController: Remove interaction on frontview when rearview is revealed

前端 未结 15 1269
迷失自我
迷失自我 2020-12-24 10:05

I need to disable user interaction on front view when rear view is revealed. Found some others asking the same thing but can\'t really understand where or how to implement t

15条回答
  •  遥遥无期
    2020-12-24 10:31

    Firstly just set your delegate : self.revealViewController.delegate = self; and the delegate method are given below :

    - (void)revealController:(SWRevealViewController *)revealController willMoveToPosition:(FrontViewPosition)position
    {
        static NSInteger tagLockView = 123456789;
        if (revealController.frontViewPosition == FrontViewPositionRight)
        {
            UIView *lockView = [self.view viewWithTag:tagLockView];
    
            [UIView animateWithDuration:0.3 animations:^{
                lockView.alpha = 0;
            } completion:^(BOOL finished) {
                [lockView removeFromSuperview];
            }];
        }
        else if (revealController.frontViewPosition == FrontViewPositionLeft)
        {
            UIView *lockView = [[UIView alloc] initWithFrame:self.view.bounds];
            lockView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
            lockView.tag = tagLockView;
            lockView.backgroundColor = [UIColor blackColor];
            lockView.alpha = 0;
            [lockView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self.revealViewController action:@selector(revealToggle:)]];
            [self.view addSubview:lockView];
            [UIView animateWithDuration:0.3 animations:^{
                lockView.alpha = 0.5;
            }];
        }
    
    }
    

提交回复
热议问题