16
在UIViewController上显示clearColor UIViewController
我UIViewController在另一个UIViewController视图之上有一个视图作为子视图/模态,例如,子视图/模态应该是透明的,添加到子视图中的任何组件都应该是可见的。问题是我有子视图显示黑色背景,而不是clearColor。我试图将其UIView作为clearColor而不是黑色背景。有人知道这是怎么回事吗?任何建议表示赞赏。 FirstViewController.m UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"]; [vc setModalPresentationStyle:UIModalPresentationFullScreen]; [self presentModalViewController:vc animated:NO]; SecondViewController.m - (void)viewDidLoad { [super viewDidLoad]; self.view.opaque = YES; self.view.backgroundColor = [UIColor clearColor]; } 解决:我已解决问题。它对于iPhone和iPad都运行良好。没有黑色背景的模态视图控制器只是clearColor / transparent。我唯一需要更改的是替换UIModalPresentationFullScreen为UIModalPresentationCurrentContext。多么简单! FirstViewController.m UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"]; vc.view.backgroundColor = [UIColor …