簡體   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