First create a view controller with your web view, call it MyWebViewController .
Then you can imagine it 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. You will need to create a center view for your content, add a border for this view and keep everything around translucent.
You can also use 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 must also implement:
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection { return UIModalPresentationNone; }
The original view is usually a button that opens the popover, but I use the parent view to ensure that the popover is centered.
You will also need to add buttons that are automatically added using the UIAlertView , but this should be trivial.
source share