OGeek|极客世界-中国程序员成长平台

标题: ios - 如何将 IOS 中的自定义 View 置于另一个 View 之上 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 10:44
标题: ios - 如何将 IOS 中的自定义 View 置于另一个 View 之上

我想通过 UIViewController 实现以下自定义 View 。实现它而不是使用 addSubview 的最佳方法是什么我想更好地使用一些东西。
我以前使用以下,但我现在想使用一些更好的东西

[self.view addSubview:NotConnected.view];

 [self.view removeFromSuperview];

enter image description here

我已经使用 https://github.com/wimagguc/ios-custom-alertview 实现了代码.

我不喜欢使用库,所以如何自定义 UIViewController 而不是另一个 UIViewController,如上图所示。我用

- (IBAction)ContinueToPaymentid)sender {

    PayByVC *Newpage = [[PayByVC alloc] initWithNibName"ayByVC" bundle:nil];
    Newpage.checkOutInfoDict=checkOutDict;
    Newpage.modalPresentationStyle   = UIModalPresentationOverCurrentContext;
    Newpage.modalTransitionStyle     = UIModalTransitionStyleCrossDissolve;
    Newpage.view.backgroundColor     = [[UIColor blackColor] colorWithAlphaComponent:.4];
    Newpage.delegate = self;
    [self presentViewController:Newpage animated:YES completion:nil];


}

要从 super View 中删除我已经使用过

 [self dismissViewControllerAnimated:YES completion:nil];

如何在所有类型的屏幕方向上将 payby View 放置在屏幕中央



Best Answer-推荐答案


使用具有 OverFullScreen 模式的模式演示。将 ViewController View 的背景设置为透明,并将您的自定义 View 放在背景的中央。

最简单的方法是使用 Storyboard。创建一个以您的自定义 View 为中心的 View Controller 。否则,您需要调用 view.addSubView(..) 将您的自定义 View 放在中心并相应地创建约束。 要呈现此 View Controller ,您可以创建一个 segue 或通过代码 presentViewController(...)。不要忘记将 modalPresentationStyle 设置为 OverFullScreen

不需要库。

关于ios - 如何将 IOS 中的自定义 View 置于另一个 View 之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30069028/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) Powered by Discuz! X3.4