繁体   English   中英

从下到上而不是从右到左关闭 UIViewController

[英]Dismiss a UIViewController from bottom to top instead of right to left

我试图从下到上关闭视图 controller 而不是标准的从右到左过渡。 这是可能吗? 这是我到目前为止的代码:

CGRect screenRect = [[UIScreen mainScreen] applicationFrame];

CGRect endFrame = self.view.frame;
endFrame.origin.y = screenRect.origin.y - screenRect.size.height;

UIView *aView = [[self.view retain] autorelease];
[self.view.window addSubview:aView];
aView.frame = CGRectMake(0, 0, 320, 460);
[UIView animateWithDuration:0.5
                 animations:^{
                     [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
                     aView.frame = endFrame;
                 }
                 completion:^(BOOL finished) {
                     [self dismissModalViewControllerAnimated:NO];
                     [aView removeFromSuperview];
                 }
 ];

这确实会导致过渡; 但是之前的视图 controller 直到 animation 之后才会出现,因为我不能在它完成之前关闭......有什么想法吗?

啊,当你呈现ModalViewController 时,它会自动将视图隐藏在后面。 您需要做的不是存在和删除,而是添加视图控制器视图作为主视图的子视图。 然后,您只需为屏幕外的视图设置动画,并在比赛处理程序中 removeFromSuperview 。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM