开发者

Dismiss a UIViewController from bottom to top instead of right to left

开发者 https://www.devze.com 2023-03-21 18:46 出处:网络
I am trying to dismiss a view controller from bottom to top instead of the standard right to left transition. Is this at all开发者_如何学Python possible? Here is the code I have so far:

I am trying to dismiss a view controller from bottom to top instead of the standard right to left transition. Is this at all开发者_如何学Python 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?


Aah, when you presentModalViewController, it automatically hides the view behind. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消