gpt4 book ai didi

ios - 如何在添加到 keyWindow 的 View 上方呈现模式?

转载 作者:行者123 更新时间:2023-12-01 16:24:55 28 4
gpt4 key购买 nike

我已将 View 添加到 [[UIApplication sharedApplication] keyWindow] ,因为我们希望它与导航栏重叠。

现在我们想点击 View 上的一个按钮并以模态方式打开一个窗口,理想情况下使用 presentViewController .有没有办法让这个模态视图出现在 keyWindow View 上方(在 z 轴上)?

我的回答

我最终添加了我的第一个自定义 UIViewControllerself.tabBarController .这允许 UIViewController重叠导航栏和标签栏。

然后我使用 [self.navigationController presentViewController:animated:completion]呈现模态,它高于 z 轴上的所有其他内容。

这是添加 UIViewController 的代码到self.tabBarController

        MyCustomViewController * overlayView = [[MyCustomViewController alloc]
initWithNibName:@"MyCustom"
bundle:nil];

UIViewController *parentViewController = self.tabBarController;
[modalView willMoveToParentViewController:parentViewController];

// set the frame for the overlayView
overlayView.view.frame = parentViewController.view.frame;

[parentViewController.view addSubview: overlayView.view];

[parentViewController.view needsUpdateConstraints];
[parentViewController.view layoutIfNeeded];

// Finish adding the overlayView as a Child View Controller
[parentViewController addChildViewController: overlayView];
[overlayView didMoveToParentViewController:parentViewController];

最佳答案

您应该重新考虑添加叠加 View 的方式。

如果您希望 View 与导航栏重叠,您可以将此 View 添加为导航栏的顶部 subview 。或者您可以将其添加为导航 Controller View 的顶部 subview 。

关于ios - 如何在添加到 keyWindow 的 View 上方呈现模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35855025/

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