[英]Dismiss a UIViewController from bottom to top instead of right to left
I am trying to dismiss a view controller from bottom to top instead of the standard right to left transition.我试图从下到上关闭视图 controller 而不是标准的从右到左过渡。 Is this at all possible?这是可能吗? Here is the code I have so far:这是我到目前为止的代码:
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];
}
];
This does result in a transition;这确实会导致过渡; but the previous view controller does not appear until after the animation since I can't dismiss until after it completes... any ideas?但是之前的视图 controller 直到 animation 之后才会出现,因为我不能在它完成之前关闭......有什么想法吗?
Aah, when you presentModalViewController, it automatically hides the view behind.啊,当你呈现ModalViewController 时,它会自动将视图隐藏在后面。 What you need to do is not present and remove, but add the view controllers view as a subview of the main view.您需要做的不是存在和删除,而是添加视图控制器视图作为主视图的子视图。 Then you just animate the view offscreen, and removeFromSuperview in the competition handler.然后,您只需为屏幕外的视图设置动画,并在比赛处理程序中 removeFromSuperview 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.