来自 2015.6.18 的笔记:改变 pushViewController 的 push 方向
代码笔记
CATransition* transition = [CATransition animation];
transition.type = kCATransitionPush;//可更改为其他方式
transition.subtype = kCATransitionFromTop;//可更改为其他方式
[self.navigationController.view.layera ddAnimation:transition forKey:kCATransition];
[self.navigationController pushViewController:userLogin animated:NO];
再来
//可根据上一个页面,来确定当前页以何种方式消失
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self clear];
BOOL fromRight = YES;
NSArray *viewControllers = self.navigationController.viewControllers;
if ([[viewControllers lastObject] isKindOfClass:[BFEAddContactViewController class]]) {
fromRight = NO;
}
CATransition *transition = [CATransition animation];
transition.type = kCATransitionPush;
//页面卸载时,改变PUSH方向
transition.subtype = fromRight ? kCATransitionFromRight : kCATransitionFromLeft;
transition.duration = 0.3;
transition.delegate = self;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
}