从另一个子视图中移除模糊视图

Remove Blur View from another subview

我在视图中添加了 2 个子视图(EOPSessionsViewController)、blurEffectViewreLogInView .

    if (!UIAccessibilityIsReduceTransparencyEnabled()) {
        self.view.backgroundColor = [UIColor clearColor];

        UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
        UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc]initWithEffect:blurEffect];
        blurEffectView.tag = 123;
        blurEffectView.frame = self.view.bounds;
        blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

        [self.view addSubview:blurEffectView];
    }else{
        self.view.backgroundColor = [UIColor blackColor];
    }

    self.reLogInView = [[ReLoginViewController alloc]initWithNibName:@"ReLoginViewController" bundle:nil];

    [self.view addSubview:self.reLogInView.view];
    self.reLogInView.view.frame = CGRectMake(0, 0, self.view.frame.size.width/2, self.view.frame.size.height/2);
    self.reLogInView.view.center = self.view.center;
    self.reLogInView.view.backgroundColor = [UIColor grayColor];
    self.reLogInView.view.layer.borderColor = [UIColor blackColor].CGColor;
    self.reLogInView.view.layer.borderWidth = 3.0f;

我想在用户单击 reLogInView 中的取消按钮时删除 blurEffectViewreLogInView .截至目前,我可以使用以下代码删除 reLogInView

- (IBAction)cancel:(id)sender {

    [self.view removeFromSuperview];

}

我的问题是如何同时移除blurEffectView?请注意,其中 3 个不同 类。

尝试添加如下内容:

self.reLogInView.sessionsVC = self;

在第一个代码片段中。 (这样声明):

@interface ReLoginViewController : (???) <???>
...
@property (strong) EOPSessionsViewController *sessionsVC;

然后:

- (IBAction)cancel:(id)sender {
    [self.view removeFromSuperview];
    [self.sessionsVC.blurEffectView removeFromSuperview];
}