n.e*_*ind 5 iphone cocoa-touch core-animation uinavigationcontroller catransition
我有一个UINavigationController.我将VC1作为rootViewController并以编程方式从VC1加载VC2,然后让自定义动画从VC1转到VC2.标准.一切都很好,很好.
现在,我想在两者之间有一个自定义动画,如下所示:

总而言之,VC1在视图之外滑动,而VC2在其下方.就像一叠纸一样,你可以滑开第一张纸(VC1),从而露出下面的纸张(VC2).
所以我尝试的是以下代码,从VC1调用以获取VC2.但它有问题:
MyVC2 *vctwo = [[[MyVC2 alloc] init] autorelease];
CATransition *transition = [CATransition animation];
transition.duration = 1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionReveal;
transition.subtype = kCATransitionFromRight;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[[self navigationController] pushViewController:vctwo animated:YES];
Run Code Online (Sandbox Code Playgroud)
问题如下:
任何建议,为什么我没有得到预期的结果将非常感谢.对不起,如果这是显而易见的,但我现在正在尝试这几个小时,真的很沮丧.
我想做到这一点的唯一方法就是忘记 UINavigationController 并提出我自己的机制来处理所有事情:
因此,如果您想在 VC 之间自定义动画,请不要使用 UINavigationController。下面是如上所述在两个 VC 之间交换的示例代码:
-(void)slideDoorOpenTo:(UIViewController *)aController duration:(float)aDuration {
[aController viewWillAppear:YES];
[activeController viewWillDisappear:YES];
//aController.view.alpha = 0.0f;
[self.view insertSubview:aController.view belowSubview:activeController.view]; // so that it is below activeController
[aController viewDidAppear:YES];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:aDuration];
aController.view.transform = CGAffineTransformMakeTranslation(0,0);
activeController.view.transform = CGAffineTransformMakeTranslation(-320,0);
[UIView commitAnimations];
[self performSelector:@selector(animationDone:) withObject:aController afterDelay:aDuration];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2408 次 |
| 最近记录: |