I want to blur my UITableView
(inside a UITableViewController
) when I present a UIAlertController
(UIAlertControllerStyleActionSheet
) but when using UIBlurEffect
and UIVisualEffectView
it doesn't blur the table view's content behind it; it just blocks it out. Happens on both simulator and device.
- (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];
}
Screenshot:
There is text content in the table view behind the action sheet that ought to be showing up as blurred, e.g. like in this image: