Objective-c 动画
2016-04-24 11:04
435 查看
想提高下以后做的应用给客户带去的体验,所以看了几天OC的CAAnimation动画类,也做了几个小案例,下面讲个别案例来做为本文的主要内容。
一:继承结构截图
View Code
一:继承结构截图
-(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:YES]; UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"LuckyCenterButton"]]; imgView.backgroundColor=[UIColor redColor]; imgView.frame = CGRectMake(100, 100, 50, 50); [self addSubview:imgView]; //贝塞尔曲线路径 UIBezierPath *movePath = [UIBezierPath bezierPath]; // 设置动画的起点坐标 [movePath moveToPoint:CGPointMake(DEVICE_Width/2-25, DEVICE_Height/2-25)]; // 、CABasicAnimation可看做是最多只有2个关键帧的CAKeyframeAnimation /* [_pushCoverMudimViewController.view.superview addSubview:_customActionSheet]; CAKeyframeAnimation *popAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; popAnimation.duration = 0.4; popAnimation.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.01f, 0.01f, 1.0f)], [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1f, 1.1f, 1.0f)], [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9f, 0.9f, 1.0f)], [NSValue valueWithCATransform3D:CATransform3DIdentity]]; popAnimation.keyTimes = @[@0.2f, @0.5f, @0.75f, @1.0f]; popAnimation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; [_customActionSheet.layer addAnimation:popAnimation forKey:nil]; */ [movePath addQuadCurveToPoint:CGPointMake(DEVICE_Width,0) controlPoint:self.view.center]; //以下必须导入QuartzCore包 // 关键帧动画(位置) CAKeyframeAnimation * posAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"]; posAnim.path = movePath.CGPath; posAnim.removedOnCompletion = YES; //缩放动画 CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"]; scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity]; //动画时的放大缩小倍数 scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.3, 0.3, 1)]; scaleAnim.removedOnCompletion = YES; //透明动画 CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"]; opacityAnim.fromValue = [NSNumber numberWithFloat:1.0]; opacityAnim.toValue = [NSNumber numberWithFloat:0.1]; opacityAnim.removedOnCompletion = YES; //动画组 CAAnimationGroup *animGroup = [CAAnimationGroup animation]; animGroup.animations = [NSArray arrayWithObjects:posAnim, scaleAnim, opacityAnim, nil]; animGroup.duration = 10; // 这里需要对动画的两个属性进行设置,让图层在完成动画后停留在动画后的状态。a animGroup.fillMode = kCAFillModeForwards; animGroup.removedOnCompletion = NO; [imgView.layer addAnimation:animGroup forKey:nil]; }
View Code
相关文章推荐
- 关于 JavaScript中的 Object.create()
- Objective-C 内存管理
- Object.prototype.toString.call() 区分对象类型
- JSONObject转换Int类型--java.lang.Integer cannot be cast to java.lang.String
- Objective-C:runtime
- OBJ-C匿名对象和封装学习笔记
- OBJ-C类方法概述学习笔记
- springmvc源码阅读笔记 --Object handler和request请求路径查询lookupPath
- Runtime全方位装逼指南
- java中流转化为Object可序列化
- ArcObjects c++ 获取栅格或矢量图层的范围
- Objective-C ARC单例模式
- [CC]ccHObject
- Object-C 基础学习(二)
- 关于用ObjectInputStream遍历读取文件中的对象,如何判断到达文件末尾
- Object-C 和 lua的相互调用
- iOS-Effective Objective-C 2.0 读书笔记(一)
- javascript系列学习----Creating objects
- object-c 快速学习篇
- 五、TypeScript 接口