您的位置:首页 > 其它

跳转方式进阶【原理是push,但是加入的动画是模态跳转方式】

2015-12-23 15:43 489 查看
今天没事研究了一下跳转方式;发现push还可以有莫泰的效果,甚至其他更多的效果;废话不多说,上代码:

//方法一:模态跳转,前提是利用navigationcontroller这个容器

// UserManagerViewController *userManagerVC = [[UserManagerViewController alloc] init];

// UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:userManagerVC];

// [self presentViewController:nav animated:YES completion:nil];

//方法二:push,只不过有莫泰跳转的方式,这种方法更好

UserManagerViewController *userManagerVC = [[UserManagerViewController alloc] init];

CATransition *animation = [CATransition animation];

animation.duration = 0.2;

animation.type = kCATransitionMoveIn;

animation.subtype = kCATransitionFromTop;

animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];

[self.navigationController.view.layer addAnimation:animation forKey:nil];

[self.navigationController pushViewController:userManagerVC animated:NO];//自定义动画,此处要设为NO
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: