gpt4 book ai didi

iOS - 具有透明度的 presentViewController

转载 作者:可可西里 更新时间:2023-11-01 04:27:35 29 4
gpt4 key购买 nike

我想半透明地全屏显示一个 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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com