一种方法是在托管视图控制器上方但在表单下方放置一个不可见的“防护罩”。
基本上,创建一个背景颜色清晰的空 UIView。在您拨打电话之前,将其作为子视图添加到您的呈现视图控制器:
[weakSelf presentViewController:navigationController animated:YES completion:^{}];
现在,这并不一定意味着这样的解决方案很有品味。也就是说,表单样式并不意味着以这种方式排他性,如果上面安装的 UIView 是清晰的,它可能会令人困惑。因此,您可以减少该视图上的 alpha 值,将其变成一个变暗的屏幕,以帮助用户了解表单是他们当时唯一可以与之交互的东西:
UIView *dimmingScreen = [[UIView alloc] initWithFrame:self.view.bounds];
dimmingScreen.alpha = 0.5; // play with this value to get different degrees of dimming
dimmingScreen.backgroundColor = [UIColor blackColor]; // play with different colors
[self.view addSubview:dimmingScreen];
// Now present your form sheet, as you were:
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[weakSelf presentViewController:navigationController animated:YES completion:^{}];
您还希望能够移除调光屏幕,因此最好将其设置为您可以访问的视图控制器属性,以便在需要时移除。