gpt4 book ai didi

ios - iOS > 8 中通过 TabBarVC 的透明 vc

转载 作者:行者123 更新时间:2023-11-29 11:34:35 24 4
gpt4 key购买 nike

有很多关于这个主题的问答,其中很多都涉及旧版本的 iOS。关于这个主题我能找到的最佳答案was this one .

它几乎对我有用,但是当通过 UITabBarViewController 子类呈现它时,它只部分起作用:在呈现动画期间我得到一个漂亮的半透明 View ,但是一旦呈现动画完成,呈现的 VC 再次变得不透明.

用 Objective-C 编码,但我很高兴阅读 Swift 的答案...

- (void)showBusyWithCompletion:(void (^)(BOOL))completion {
UIViewController *vc = [[UIViewController alloc] init];

vc.view.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.5];
vc.view.opaque = NO;

vc.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:vc animated:YES completion:^{
[self performSelector:@selector(hideBusy:) withObject:vc afterDelay:4];
}];
}

- (void)hideBusy:(UIViewController *)vc {
[self dismissViewControllerAnimated:vc completion:nil];
}

同样,呈现的 VC 是一个 UITabBarVC 子类,除了一些代码来记录访问了哪些选项卡之外,没有对它做任何事情。呈现的 vc 是一个普通的 View Controller 。它的 View 在滑过时显示为透明的红色,然后在过渡完成后变为不透明的红色(更暗,就像它与黑色混合)。

背景出现后如何保持透明?

最佳答案

原来我上面的答案是对的,是我抄写的设置不对。回顾一下:这是行不通的(另一个答案并没有声称它行得通):

vc.modalPresentationStyle = UIModalPresentationCurrentContext;

...但是其中任何一个都可以:

vc.modalPresentationStyle = UIModalPresentationOverFullScreen;

或者正如@TylerTheCompiler 指出的那样:

vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;

关于ios - iOS > 8 中通过 TabBarVC 的透明 vc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50490681/

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