First, create a view controller with your web view, let's call it MyWebViewController
.
Then you can present it either as a full screen controller:
MyWebViewController* alertController = [[MyWebViewController alloc] init];
alertController.view.backgroundColor = [UIColor.lightGrayColor colorWithAlphaComponent:0.2];
alertController.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:alertController animated:YES completion:nil];
This is a full screen controller though. You will have to create a view in the center for your content, add a border for that view and keep everything around semitransparent.
You can also use a popover:
UIView *sourceView = self.view;
MyWebViewController* alertController = [[MyWebViewController alloc] init];
alertController.modalPresentationStyle = UIModalPresentationPopover;
alertController.preferredContentSize = CGRectInset(self.view.bounds, 20, 100).size;
alertController.popoverPresentationController.canOverlapSourceViewRect = YES;
alertController.popoverPresentationController.sourceView = sourceView;
alertController.popoverPresentationController.sourceRect = CGRectMake(CGRectGetMidX(sourceView.bounds), CGRectGetMidY(sourceView.bounds), 0, 0);
alertController.popoverPresentationController.permittedArrowDirections = 0;
alertController.popoverPresentationController.delegate = self;
[self presentViewController:alertController animated:YES completion:nil];
The delegate also has to implement:
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection {
return UIModalPresentationNone;
}
The source view is usually the button which opens the popover but I am using the parent view to ensure the popover is centered.
You will also have to add the buttons which are added automatically by UIAlertView
but that should be trivial.