【发布时间】:2012-07-28 00:35:50
【问题描述】:
我正在尝试制作自定义 segue,以便目标视图控制器从顶部向下滑动。
我根据the documentation的示例编写了我的代码。
问题是当segue执行时,源视图控制器变黑,然后出现动画。如何防止源视图控制器变黑?
(我已经尝试实现this answer 中提出的解决方案,但屏幕要么在转换后变黑,要么恢复到源视图控制器。)
这是我的代码:
-(void)perform{
UIViewController *splashScreen = self.sourceViewController;
UIViewController *mainScreen = self.destinationViewController;
//Place the destination VC above the visible area
mainScreen.view.center = CGPointMake(mainScreen.view.center.x,
mainScreen.view.center.y-600);
//Animation to move the VC down into the visible area
[UIView animateWithDuration:1
animations:^{
mainScreen.view.center = CGPointMake(mainScreen.view.center.x, [[UIScreen mainScreen] bounds].size.height/2 );
}
];
[splashScreen presentModalViewController:mainScreen animated:NO];
}
【问题讨论】:
-
解决方案非常简单。您必须在呈现新的视图控制器之前完成动画。没有别的了。
标签: ios core-animation uistoryboard uistoryboardsegue