0

我想在呈现 ( ) 时模糊我的UITableView( 内部) 但是在使用时它不会模糊它后面的表格视图的内容;它只是阻止它。发生在模拟器和设备上。UITableViewControllerUIAlertControllerUIAlertControllerStyleActionSheetUIBlurEffectUIVisualEffectView

- (void)showAlert {
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];

    UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    visualEffectView.frame = CGRectMake(0, self.tableView.contentOffset.y, self.view.frame.size.width, self.view.frame.size.height);

    [self.view addSubview:visualEffectView];

    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Alert Title" message:@"Alert Message" preferredStyle:UIAlertControllerStyleActionSheet];

    [alert addAction:[UIAlertAction actionWithTitle:@"Action 1" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        // handle choice...

        [visualEffectView removeFromSuperview];
    }]];

    [alert addAction:[UIAlertAction actionWithTitle:@"Action 2" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        // handle choice...

        [visualEffectView removeFromSuperview];
    }]];

    [self presentViewController:alert animated:YES completion:nil];
}

截屏:

在此处输入图像描述

操作表后面的表格视图中有文本内容应该显示为模糊,例如,如下图所示:

在此处输入图像描述

4

1 回答 1

-1

我已经尝试过查看并且效果很好。我对你的代码做了一些改动。

 - (void)showAlert {
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];

    UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    visualEffectView.frame = CGRectMake(0, self.view.frame.size.height/2, self.view.frame.size.width, self.view.frame.size.height);

    //self.vBlur.backgroundColor = [UIColor clearColor];
    [self.view addSubview:visualEffectView];

    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Alert Title" message:@"Alert Message" preferredStyle:UIAlertControllerStyleActionSheet];

    [alert addAction:[UIAlertAction actionWithTitle:@"Action 1" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        // handle choice...

        [visualEffectView removeFromSuperview];
    }]];

    [alert addAction:[UIAlertAction actionWithTitle:@"Action 2" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        // handle choice...

        [visualEffectView removeFromSuperview];
    }]];

    [self presentViewController:alert animated:YES completion:nil];
}

截屏

另一个截图?

于 2016-06-29T04:36:37.010 回答