试图通过UITableViewController模糊UIAlertController后面的UITableView

时间:2016-06-28 21:34:24

标签: ios objective-c uitableview uivisualeffectview uiblureffect

当我提出UITableViewUITableViewController)但使用UIAlertController和{{1}时,我希望模糊我的UIAlertControllerStyleActionSheetUIBlurEffect内)它不会模糊表格视图背后的内容;它只是阻止了它。在模拟器和设备上都会发生。

UIVisualEffectView

截图:

enter image description here

行动表后面的表格视图中的文字内容应该显示为模糊,例如就像在这张图片中一样:

enter image description here

1 个答案:

答案 0 :(得分:-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];
}

screenshot

another screenshot?