[IOS笔记] - 动画animation
//移动
- (IBAction)translation:(id)sender {
CABasicAnimation *traslation = [CABasicAnimation animationWithKeyPath:@"position"];
traslation.toValue = [NSValue valueWithCGPoint:CGPointMake(,)];
traslation.duration = 2.0;
//traslation.autoreverses = YES;
traslation.repeatCount = ; [self.m_image.layer addAnimation:traslation forKey:@"traslation"];
} //透明
- (IBAction)opacity:(id)sender {
CABasicAnimation *opacity = [CABasicAnimation animationWithKeyPath:@"opacity"];
opacity.fromValue = [NSNumber numberWithFloat:1.0];
opacity.toValue = [NSNumber numberWithFloat:0.4];
opacity.duration = 0.2; //动画时间
opacity.repeatCount = FLT_MAX; //永久
opacity.autoreverses = YES; //每次动画后倒回回放
opacity.removedOnCompletion=NO; //动画后不还原,为no时不回到最初状态
opacity.fillMode=kCAFillModeForwards; [self.m_image.layer addAnimation:opacity forKey:@"opacity"];
} // 旋转
- (IBAction)rotate:(id)sender {
CATransform3D ca3d = CATransform3DMakeRotation( * 3.14159265/180.0, -, , ); CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
rotate.toValue = [NSValue valueWithCATransform3D:ca3d];
rotate.duration=1.0;
rotate.autoreverses=NO;
rotate.repeatCount=;
rotate.removedOnCompletion=NO;
rotate.fillMode=kCAFillModeForwards;
[self.m_image.layer addAnimation:rotate forKey:@"rotate"];
} - (IBAction)alpha:(id)sender {
} //缩放
- (IBAction)scale:(id)sender {
CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scale.fromValue=[NSNumber numberWithFloat:0.5];
scale.toValue = [NSNumber numberWithFloat:2.0];
scale.duration=1.0;
scale.autoreverses=YES;
scale.repeatCount=;
scale.removedOnCompletion=YES;
scale.fillMode=kCAFillModeForwards;
[self.m_image.layer addAnimation:scale forKey:@"scale"];
} //不按原始边长度缩放
-(IBAction)bounds:(id)sender{
CABasicAnimation *bounds = [CABasicAnimation animationWithKeyPath:@"bounds"];
bounds.duration = .f;
bounds.fromValue = [NSValue valueWithCGRect:CGRectMake(,,,)];
bounds.toValue = [NSValue valueWithCGRect:CGRectMake(,,,)];
bounds.byValue = [NSValue valueWithCGRect:self. m_image.bounds]; bounds.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
bounds.repeatCount = ;
bounds.autoreverses = YES; [self.m_image.layer addAnimation:bounds forKey:@"bounds"];
} - (IBAction)path:(id)sender {
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, nil, , );
//添加直线路径
CGPathAddLineToPoint(path, NULL, , );
CGPathAddLineToPoint(path, NULL, , );
CGPathAddLineToPoint(path, NULL, , );
CGPathAddLineToPoint(path, NULL, , );
CGPathAddLineToPoint(path, NULL, , );
//添加曲线路径
CGPathAddCurveToPoint(path,NULL,50.0,275.0,150.0,275.0,70.0,120.0);
CGPathAddCurveToPoint(path,NULL,150.0,275.0,250.0,275.0,90.0,120.0);
CGPathAddCurveToPoint(path,NULL,250.0,275.0,350.0,275.0,110.0,120.0);
CGPathAddCurveToPoint(path,NULL,350.0,275.0,450.0,275.0,130.0,120.0); animation.path = path;
animation.duration = ;
animation.autoreverses = YES;
[self.m_image.layer addAnimation:animation forKey:@"path"];
CFRelease(path);
}
//组合动画
- (IBAction)goup:(id)sender {
CAAnimationGroup *group = [CAAnimationGroup animation]; CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scale.fromValue=[NSNumber numberWithFloat:0.5];
scale.toValue = [NSNumber numberWithFloat:2.0]; CABasicAnimation *traslation = [CABasicAnimation animationWithKeyPath:@"position"];
traslation.toValue = [NSValue valueWithCGPoint:CGPointMake(,)]; group.animations=[NSArray arrayWithObjects:scale, traslation, nil];
group.duration = 2.0; [self.m_image.layer addAnimation:group forKey:@"group"];
}
[IOS笔记] - 动画animation的更多相关文章
- 《The Cg Tutorial》阅读笔记——动画 Animation
这段时间阅读了英文版的NVidia官方的<The Cg Tutorial>,借此来学习基本的图形学知识和着色器编程. 在此做一个阅读笔记. 本文为大便一箩筐的原创内容,转载请注明出处,谢谢 ...
- iOS开发--动画(Animation)总结
UIView的,翻转.旋转,偏移,翻页,缩放,取反的动画效果 翻转的动画 //开始动画 [UIView beginAnimations:@"doflip" context:ni ...
- iOS开发动画(Animation)总结
UIView的,翻转.旋转,偏移,翻页,缩放,取反的动画效果 翻转的动画 //开始动画 [UIView beginAnimations:@"doflip" context:ni ...
- 荼菜的iOS笔记--UIView的几个Block动画
前言:我的第一篇文章荼菜的iOS笔记–Core Animation 核心动画算是比较详细讲了核心动画的用法,但是如你上篇看到的,有时我们只是想实现一些很小的动画,这时再用coreAnimation就会 ...
- Android动画学习笔记-Android Animation
Android动画学习笔记-Android Animation 3.0以前,android支持两种动画模式,tween animation,frame animation,在android3.0中 ...
- iOS 核心动画 Core Animation浅谈
代码地址如下:http://www.demodashi.com/demo/11603.html 前记 关于实现一个iOS动画,如果简单的,我们可以直接调用UIView的代码块来实现,虽然使用UIVie ...
- amazeui学习笔记--css(常用组件15)--CSS动画Animation
amazeui学习笔记--css(常用组件15)--CSS动画Animation 一.总结 1.css3动画封装:CSS3 动画封装,浏览器需支持 CSS3 动画. Class 描述 .am-anim ...
- iOS核心动画学习整理
最近利用业余时间终于把iOS核心动画高级技巧(https://zsisme.gitbooks.io/ios-/content/chapter1/the-layer-tree.html)看完,对应其中一 ...
- IOS 核心动画之CAKeyframeAnimation - iBaby
- IOS 核心动画之CAKeyframeAnimation - 简单介绍 是CApropertyAnimation的子类,跟CABasicAnimation的区别是:CABasicAnimation ...
随机推荐
- CDH4 journalnode方式手工安装手册之一
一. 环境部署概况 cdh-master 172.168.10.251 cdh-node1 172.168.10.251 cdh-no ...
- src与href的区别
href: 是指向网络资源所在位置,建立和当前元素(锚点)或当前文档(链接)之间的链接,用于超链接. src:是指向外部资源的位置,指向的内容将会嵌入到文档中当前标签所在位置:在请求src资源时会将其 ...
- [每日app二]月入60万多嘛?单词锁屏的潜力!
抢了用户的时间,就是抢了用户的金钱! 单词锁屏,一个开发难度不太大,但仅仅360手机助手下载就是每周4万!拉风- 对于搞app的同学来说,搞个锁屏,还不是玩似的,但是要定位好,玩得好,那就有难度了.最 ...
- VMware Workstation 14 PRO 下安装Ubuntu 16.04 LTS教程
一.准备好安装的VMware Workstation 14 PRO 1.VMware Workstation 14 PRO下载链接:http://rj.baidu.com/soft/detail/13 ...
- PHP协程是通过生成器实现的,这里测试了PHP生成器的一些特性
学习PHP的生成器,测试了一些特性.代码如下: function gen() { $name = (yield 'hello'); $nickname = (yield 'world'); yield ...
- [LOJ#113]最大异或和
[LOJ#113]最大异或和 试题描述 这是一道模板题. 给由 n 个数组成的一个可重集 S,求一个集合 T⊆S,使 T1 xor T2 xor … xor T|T| 最大 输入 第一行一个数 n.第 ...
- Codeforces - Avito Code Challenge 2018
Portal A. Antipalindrome 暴力. B. Businessmen Problems 暴力. C. Useful Decomposition 居然不是C打头的?! 将一棵树划分成若 ...
- java面试题之什么是线程ThreadLocal?作用是什么?
定义:线程局部变量是局限于线程内的变量,属于线程自身所有,不在多个线程间共享.java提供ThreadLocal类来支持线程局部变量,是一个实现线程安全的方式. 任何线程局部变量一旦在工作完成后没有释 ...
- Django标签之包含标签Inclusion tags
Django过滤器和标签功能很强大,而且支持自定义标签,很是方便:其中一种标签是Inclusion tags,即包含标签,个人感觉比较反人类的 包含标签(Inclusion tags)通过渲染其他的模 ...
- 开源编辑器ueditor
http://ueditor.baidu.com/website/onlinedemo.html