【代码笔记】iOS-Transition动画
2017-06-15 09:10
225 查看
一,工程图。
二,代码。
RootViewController.h
RootViewController.m
二,代码。
RootViewController.h
#import <UIKit/UIKit.h> @interface RootViewController : UIViewController @end
RootViewController.m
#import "RootViewController.h" #import "FirstViewController.h" @interface RootViewController () @end @implementation RootViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.title=@"首页"; self.view.backgroundColor=[UIColor redColor]; /* 过渡效果 fade //交叉淡化过渡(不支持过渡方向) push //新视图把旧视图推出去 moveIn //新视图移到旧视图上面 reveal //将旧视图移开,显示下面的新视图 cube //立方体翻滚效果 oglFlip //上下左右翻转效果 suckEffect //收缩效果,如一块布被抽走(不支持过渡方向) rippleEffect //滴水效果(不支持过渡方向) pageCurl //向上翻页效果 pageUnCurl //向下翻页效果 cameraIrisHollowOpen //相机镜头打开效果(不支持过渡方向) cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向) */ /* 过渡方向 fromRight; fromLeft; fromTop; fromBottom; */ } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ CATransition *transition = [CATransition animation]; // 动画时间控制 transition.duration = 0.3f; //动画的开始与结束的快慢 transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; //是否代理 transition.delegate = self; //此动画执行完后会自动remove,默认值为true transition.removedOnCompletion = NO; //各种动画效果 transition.type = kCATransitionMoveIn; //动画方向 transition.subtype = kCATransitionFromTop; FirstViewController *viewCon = [[FirstViewController alloc]init]; [self.navigationController pushViewController:viewCon animated:NO]; // 想添加CA动画的VIEW的层上添加此代码 [self.navigationController.view.layer addAnimation:transition forKey:nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
相关文章推荐
- 【代码笔记】iOS-Transition动画
- 【代码笔记】iOS-伸缩式动画
- IOS cocos2d学习笔记-<七>CCTransitionScene场景切换动画
- iOS笔记 页面切换 CATransition Animation动画
- 【代码笔记】iOS-字体抖动动画
- 【代码笔记】iOS-动画的跳转
- 【代码笔记】iOS-浇花动画
- ios动画笔记(2)CATransform3D和CASpringAnimation 、CATransition和CAEmitterLayer、UIDynamicAnimator
- 【代码笔记】iOS-动画的跳转
- 【代码笔记】iOS-字体抖动动画
- 【代码笔记】iOS-拍照动画
- iOS学习笔记-078.核心动画04——CATransition(转场动画)
- ios 动画效果CATransition笔记
- 第二章、小实例,画字,画线,矩形,画图,动画(iOS学习笔记,从零开始。)
- 【iOS动画技术笔记】
- ios学习笔记---用View动画仿UC浏览器菜单栏弹出效果
- 转 ios常用的几个动画代码
- ios开发代码笔记
- ios常用的几个动画代码
- [IOS笔记] - 动画animation