在iOS 7之前,根据这个流行的Stackoverflow 问题, 显示透明背景的ViewController的方法是在主ViewController中执行以下操作:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];
vc.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:vc animated:NO completion:nil];
然而,最近我在使用iOS 7时发现(并且其他人也在主回答中评论过),上述解决方案不再适用,而只是显示黑色的模态控制器。我知道透明度在iOS 7中被广泛使用,因此透明的视图控制器很可能是可行的。我还没有找到解决此问题的方法,并想知道是否有人知道如何解决这个问题。谢谢!
modalPresentationStyle
的文档现在说明:“在 iPhone 和 iPod touch 上,模态视图控制器始终以全屏方式呈现,但在 iPad 上有几种不同的呈现选项”。因此我认为 Apple 在 iOS 7 中将其从 iPhone 上移除了。 - Ortwin Gentz