http://segmentfault.com/q/1010000000143983

默认的UINavigationController push和pop的默认动画都是左右滑动推出,我的应用要求这种界面切换的动画效果复杂一点,大概有这么几个:

  • 更快的左右推出,默认是0.3秒,我需要快一倍
  • 带抖动的左右推出
  • 水平翻转
  • 纸张翻页效果

但是这些切换都要放在NavigationController里做管理,怎么实现,求个思路

3 个回答

答案对人有帮助,有参考价值0答案没帮助,是错误的答案,答非所问
采纳
yuanlizbyy 275 2012年11月28日 回答

1. 如果楼主想要使用UINavigationController中的view controller stack,并且还想要同时自定义push、pop的动画效果,基本上是不可能的。原因在于想要使用view controller stack,就无法躲开
pushViewController:animated:这个方法,而一旦使用pushViewController:animated:,UINavigationController就会强制将要推入的viewController的frame设为当前可视区域的frame,从而断绝一切想要自定义动画的后路,例如如下代码,是不会产生任何效果的:

UINavigationController+CustomAnimation.h

@interface UINavigationController (CustomAnimation)

- (void)customPushViewController:(UIViewController *)viewController;

@end

UINavigationController+CustomAnimation.m

#import "UINavigationController+CustomAnimation.h"

- (void)customPushViewController:(UIViewController *)viewController
{
viewController.view.frame = (CGRect){0, -viewController.view.frame.size.height, viewController.view.frame.size};
[self pushViewController:viewController animated:NO];
[UIView animateWithDuration:.15f
animations:^{
viewController.view.frame = (CGRect){0, 0, self.view.bounds.size};
}];
}

2. 如果仅仅是想添加自定义的push、pop动画,而不使用view controller stack,那么,如下代码就可以实现一个从上到下的push效果:

UINavigationController+CustomAnimation.h文件同上。

UINavigationController+CustomAnimation.m

#import "UINavigationController+CustomAnimation.h"
- (void)customPushViewController:(UIViewController *)viewController
{
viewController.view.frame = (CGRect){0, -viewController.view.frame.size.height, viewController.view.frame.size};
[self.topViewController.view addSubview:viewController.view];
[UIView animateWithDuration:.15f
animations:^{
viewController.view.frame = (CGRect){0, 0, self.view.bounds.size};
}];
}
答案对人有帮助,有参考价值2答案没帮助,是错误的答案,答非所问
navy 1.7k 2012年11月24日 回答

虽然基于navctrl,但是你可以不用navctrl push的方法,可以用viewctrl的presentModalViewController。至于速度的话,这些系统的默认都是0.3s,动画方式也就是系统默认的几个。
如果需要各种自定义动画,能自定义动画的是view,给个例子http://www.cocoachina.com/bbs/read.ph...,供楼主参考下。

答案对人有帮助,有参考价值1答案没帮助,是错误的答案,答非所问
FinnChen 93 2012年11月23日 回答

 

撰写答案

 

最新文章

  1. webpack踩坑之路——构建基本的React+ES6项目
  2. margin双边距的问题
  3. nginx 支持laravel 5.3配置
  4. IIS7.0 Appcmd 命令详解和定时重启应用池及站点的设置
  5. 使用Xamarin.Forms平台开发移动应用指南
  6. sqlserver游标的使用方式
  7. java连接mysql(一)
  8. MySql 分组排序取时间最大的一条记录
  9. js的相关验证
  10. cf C. Xenia and Weights
  11. Linux下检测进程是否存在
  12. Spring_Spring与AOP
  13. SpriteBuilder中使用TrueType字体的一些障碍
  14. [转]快速新建简单的koa2后端服务
  15. gooderp安装
  16. C/C++ 动态存储分配 malloc calloc realloc函数的用法与区别
  17. CentOS6.8配置SonarQube Scanner配合SonarQube使用
  18. 微信小程序倒计时组件开发
  19. system表空间不可改名
  20. P3302 [SDOI2013]森林

热门文章

  1. Jmeter从文件中读取参数值
  2. 机器学习/逻辑回归(logistic regression)/--附python代码
  3. [leetcode-640-Solve the Equation]
  4. Linux SPI总线和设备驱动架构之一:系统概述
  5. chrome谷歌浏览器导致的密码被修改现象
  6. linux下生成core dump文件方法
  7. (转)部署MongoDB时需要注意的调参
  8. Struts1表单校验
  9. 2017北大校赛 J题 pairs
  10. vThunder 安装