Additive属性动画

参考

http://ronnqvi.st/multiple-animations/

效果

源码

https://github.com/YouXianMing/Animations

//
//  AdditiveAnimationController.m
//  Animations
//
//  Created by YouXianMing on 16/1/21.
//  Copyright © 2016年 YouXianMing. All rights reserved.
//

#import "AdditiveAnimationController.h"
#import "UIView+SetRect.h"@interface AdditiveAnimationController ()@property (nonatomic, strong) CALayer  *layer;@end@implementation AdditiveAnimationController- (void)setup {[super setup];// http://ronnqvi.st/multiple-animations/
    self.layer                 = [CALayer layer];self.layer.frame           = CGRectMake(0, 0, 30, 30);self.layer.backgroundColor = [UIColor redColor].CGColor;self.layer.cornerRadius    = 15.f;self.layer.position        = self.contentView.middlePoint;[self.contentView.layer addSublayer:self.layer];UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapEvent:)];[self.contentView addGestureRecognizer:tap];
}- (void)tapEvent:(UITapGestureRecognizer *)tapGesture {CGPoint touchPoint      = [tapGesture locationInView:tapGesture.view];CGPoint differencePoint = CGPointMake(self.layer.position.x - touchPoint.x,self.layer.position.y - touchPoint.y);CALayer *presentationLayer = self.layer.presentationLayer;NSLog(@"%@", presentationLayer);CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];animation.duration          = 1.f;animation.timingFunction    = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];animation.additive          = true;animation.fromValue         = [NSValue valueWithCGPoint:differencePoint];animation.toValue           = [NSValue valueWithCGPoint:CGPointZero];[CATransaction begin];[CATransaction setDisableActions:YES];self.layer.position = touchPoint;[CATransaction commit];[self.layer addAnimation:animation forKey:nil];
}@end

细节

Additive属性动画相关推荐

  1. Android 属性动画(Property Animation) ObjectAnimator的介绍

    先说下属性动画与视图动画的区别: 视图动画系统仅提供为 View 对象添加动画效果的功能,因此,如果您想为非 对象添加动画效果,则必须实现自己的代码才能做到.视图动画系统也存在一些限制,因为它仅公开 ...

  2. Android 属性动画(Property Animation) ValueAnimator 的介绍

    先说下属性动画与视图动画的区别: 视图动画系统仅提供为 View 对象添加动画效果的功能,因此,如果您想为非 对象添加动画效果,则必须实现自己的代码才能做到.视图动画系统也存在一些限制,因为它仅公开 ...

  3. Android Property Animation属性动画:scale缩放动画(4)

     Android Property Animation属性动画:scale缩放动画(4) 和之前我写的附录文章1,2,3相似,本文将接着使用Android Property Animation属性 ...

  4. 每日一道面试题(第7期)---Android补间动画与属性动画的区别

    零零碎碎的东西总是记不长久,仅仅学习别人的文章也只是他人咀嚼后留下的残渣.无意中发现了这个每日一道面试题,想了想如果只是简单地去思考,那么不仅会收效甚微,甚至难一点的题目自己可能都懒得去想,坚持不下来 ...

  5. Android源码解析(一)动画篇-- Animator属性动画系统

    Android源码解析-动画篇 Android源码解析(一)动画篇-- Animator属性动画系统 Android源码解析(二)动画篇-- ObjectAnimator Android在3.0版本中 ...

  6. 这可能是第二好的自定义 View 教程之属性动画

    上期文章镇楼: 这可能是第二好的自定义 View 教程之绘制 凯哥的文章确实写的细而好呀,这不,活生生把 面试系列 先放一放,继续讲解我们的动画. 为啥是第二好? 一看就是没看 前面的文章 的.这里就 ...

  7. Android属性动画源代码解析(超详细)

    本文假定你已经对属性动画有了一定的了解,至少使用过属性动画.下面我们就从属性动画最简单的使用开始. ObjectAnimator.ofInt(target,propName,values[]).set ...

  8. 【Android 属性动画】属性动画 Property Animation 与 视图动画 View Animation 区别

    文章目录 一.动画效果添加对象 二.动画效果类型 三.动画效果与实际属性 四.开发复杂程度 属性动画 Property Animation 可以为 任何对象 ( View 对象 / 非 View 对象 ...

  9. 【Android 属性动画】属性动画 Property Animation 工作原理 ( 线性插值动画 | 非线性插值动画 | 动画计算 | 经过分数 | 插值分数 | 类型估值器)

    文章目录 一.线性插值动画示例 二.非线性插值动画示例 三.动画计算方式 四.时间经过分数 ( Elapsed Fraction ) 五.插值分数 ( Interpolated Fraction ) ...

最新文章

  1. arrays must all be same length
  2. 面向人工智能的计算机体系结构
  3. 当一个美术生开始在腾讯撸代码… |「递归」第1集
  4. (转)ArcObjects SDK(AE)10.1在vs2012安装的方法
  5. 学习scala03 控制结构
  6. python如何测试rabbit_Python如何检测到我的RabbitMQ密码失败?
  7. 2011—2018年软考中级数据库系统工程师历年真题
  8. css一些需要注意的东西
  9. 淘宝自动发货源码,网店自动值守发货系统 不限制域名 支持客户自助提货及自动评价...
  10. 2022新版彩虹易支付系统源码支持当面付通道轮询第三方支付免签约
  11. 深度学习实战(十一)——多标签分类(基于Keras)
  12. 408复习策略(强化阶段)
  13. 安卓机适合用的手机浏览器,可下载视频可锁屏
  14. 个人所得税计算器 微信小程序开发 计算差值方法
  15. 马鞍线 matlab,使用matlab编程,怎样画出心形线和马鞍面?
  16. 哈哈,又找到几个强大的html5+css3的动画效果
  17. python-闰年判断
  18. c++书本中没有的小点心
  19. 【洛谷新手村解题报告二】C++语言,一题多解,思路和WA反思
  20. TypeError: can only concatenate str (not “list“) to str(报错解决办法)

热门文章

  1. 图论中的知识点(等待补充和更新)
  2. iOS linker command failed with exit code 1 (use v to see invocation)
  3. 转转转![Spring MVC] - 500/404错误处理-SimpleMappingExceptionResolver
  4. sqlmap工具命令行的含义
  5. 面对 20 亿行代码,Google 如何管理?
  6. Sqrt(int x) leetcode java
  7. 使用DotNetCharting控件生成报表统计图总结
  8. 新浪微博封装类,以及常见问题sdk修改
  9. “后 PC”时代,应用为王
  10. 网络管理员&MCSE2003之12: 第8章 应用管理模板和审核策略