我想半透明地全屏显示一个 View Controller ,这样我仍然可以看到它下面的 View 。下面的代码展示了新的 View Controller ,但它取代了当前的 View Controller 。保持原始 View Controller 可见的最佳方法是什么?新 View Controller 的 View 将具有半透明的黑色背景。
NewViewController* newVC = [[NSClassFromString(@"NewViewController") alloc] initWithNibName:deviceNib bundle:nil];
newVC.modalPresentationStyle = UIModalPresentationFullScreen;
newVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:newVC animated:YES completion:NULL];
最佳答案
呈现半透明 View ,而不是 View Controller 。
mySemiTransparentView.alpha = 0.0f;
[self.view addSubview:mySemiTransparentView];
mySemiTransparentView 是您的全屏 View 。您可以将其设置为动画:
[UIView beginAnimations:@"fadeIn" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.4f];
mySemiTransparentView.alpha = 0.5f;
[UIView commitAnimations];
关于iOS - 具有透明度的 presentViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11890205/