简体   繁体   English

如何在另一个ViewController之上显示一个ViewController?

[英]How can I present one ViewController on top of another ViewController?

Let's say I have a class that is a subclass of UIViewController named FullSizeViewController . 假设我有一个类,它是UIViewController的子类,名为FullSizeViewController I also have another class that is a subclass of UIViewController called TQHViewController (TQH: Three Quarter Height). 我还有另一个类,它是UIViewController的子类,称为TQHViewControllerTQHViewController :四分之三高度)。 How would I 我怎么会

  1. be able to display TQHViewController over FullSizeViewController , with the only one quarter of FullSizeViewController visible? 能够显示TQHViewController超过FullSizeViewController ,用的只有四分之一FullSizeViewController可见?

  2. animate this action? 动画这个动作?

I'm basically attempting to make something like a UIPopover , but animate it so it slides in from the bottom of the screen. 我基本上是在尝试制作类似UIPopover东西,但是要对其进行动画处理,以使其从屏幕底部滑入。

@property(nonatomic,retain) TQHViewController   *template;

template = [[TQHViewController alloc]init];
template.view.frame = CGRectMake(20, 1000, 280, 450);

And you can also set the frame for the subView and decide the size of the subview. 您还可以设置子视图的框架并确定子视图的大小。 if you want animation from the bottom use UIViewwithanimation. 如果要从底部开始动画,请使用UIViewwithanimation。

 [UIView animateWithDuration:0.9f
                      delay:0.1f
     usingSpringWithDamping:0.65f
      initialSpringVelocity:0.1f
                    options:UIViewAnimationOptionCurveEaseOut animations:^{
                template.view.frame = CGRectMake(20, 63, 280, 450);
                [self.view addSubview:overlayWindow];

               }

                 completion:^(BOOL finished) {
                     //Completion Block
  }];

Use like this so your functionalities will not be lost and make nill after the usage. 像这样使用,这样您的功能将不会丢失,并且在使用后不会失效。

If anything wrong feel free to comment it. 如果有任何问题,请随时发表评论。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在导航控制器中从下到上呈现/关闭视图控制器? - How can i present/dismiss viewcontroller from bottom to top in navigationcontroller? 当我仍然可以看到背景viewController时,如何呈现viewController - How to present viewController while I can still see the background viewController 如何在全屏ViewController上显示一个小ViewController - How do you present One small ViewController on Top of a full screen ViewController 如何将一个ViewController或View加载到具有透明背景的另一个ViewController中? - How can I load a ViewController or View into another ViewController with transparent background? 如何在另一个ViewController上部分呈现ViewController并仍然能够与最底层的ViewController交互? - How to present ViewController partially over another ViewController and still be able to interact with the bottom one? 我如何在一个不知道新VC的VC之上呈现另一个ViewController? - How do I present a ViewController over another with that VC having no knowledge of the new one? 如何在另一个 TabController 中选择 ViewController? - How can I segue to a ViewController in another TabController? 如何在 Swift 中呈现 VC 并设置为新的 Root viewController? - How can I present VC and set as new Root viewController in Swift? 如何从接触点呈现ViewController? - How can I present a ViewController from a touch point? 如何在单独的 UIWindow 中呈现另一个 viewController - how to present another viewController in separate UIWindow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM