Cover image
Hero image

托码特人

分享科技与人文

一个关注互联网的技术博客

改变pushViewController的push方向

来自 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];
}
赞赏

声明: 本文内容由托码斯创作整理,由于知识水平和时效性问题,行文可能存在差错,欢迎留言交流。读者若需转载,请保留出处,谢谢!