請參閱下面的試試。只需要從下面的方法調用NewViewController.What你需要做的就是你只需要改變NewViewcOntroller的視圖框的OriginY。
-(void)displayNewVC
{
YourNewViewController *newVC = [[YourNewViewController alloc] init];
CGFloat originY = -450;//set originY as you want to display newViewController from the Top to bottom with animation
//initially set originY out of the Frame of CurrentViewcontroller
newVC.view.frame = CGRectMake(orginX, originY, newVC.view.frame.size.width, newVC.view.frame.size.height);
/*Display View With Animation*/
originY = 300;
[UIView animateWithDuration:.3 animations:^{
//set new originY as you want.
newVC.view.frame = CGRectMake(orginX, originY, newVC.view.frame.size.width, newVC.view.frame.size.height);
} completion:NULL];
[currentViewController.view addSubview:newVC.view];
}
我希望它可以幫助你。
你能解釋'animateWithDuration'調用中的原始用法嗎? – Asahi 2013-05-04 19:03:57
@Asahi它會顯示您在CurrentViewController中顯示您的NewViewControler的地方。我剛剛舉了一個例子,只是試一試.... – Kamarshad 2013-05-04 19:06:50
它沒有在您的原始答案中使用。好吧 - 試試。 – Asahi 2013-05-04 19:09:49