SWRevealViewController close rear view when tapping front view

前端 未结 9 1617
夕颜
夕颜 2020-12-09 04:18

I am using SWRevealViewController in order to implement a side nav menu in my app. I would like to make it so that the front view cannot be interacted with when

9条回答
  •  一个人的身影
    2020-12-09 05:15

    Put below code on menu view controller its works for me

    @interface SidebarTableViewController() {
        UIView* coverView;
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [coverView removeFromSuperview];
        //[self.revealViewController.frontViewController.view setUserInteractionEnabled:YES];
        // get your window screen size
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        // get your window screen size
        CGRect screenRect = [[UIScreen mainScreen] bounds];
        //create a new view with the same size
        coverView = [[UIView alloc] initWithFrame:screenRect];
        // change the background color to black and the opacity to 0.6
        coverView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
        // add this new view to your main view
        [self.revealViewController.frontViewController.view addSubview:coverView];
        // [self.revealViewController.frontViewController.view setUserInteractionEnabled:NO];
    }
    

提交回复
热议问题