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(, , , );
self.layer.backgroundColor = [UIColor redColor].CGColor;
self.layer.cornerRadius = .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 = .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

细节

最新文章

  1. webstorm 配置scss的问题
  2. 在VMware下正确克隆CentOS6.5的打开方式
  3. xml文件格式说明
  4. iOS开发笔记6:图片轮播及其无限循环效果
  5. 在Linux下用fdisk创建分区
  6. php 使用phpmailer 发送邮件(附带中文乱码的解决方法)
  7. Netty 中文教程 Hello World !详解
  8. Android 自定义控件玩转字体变色 打造炫酷ViewPager指示器
  9. 透过表象看本质!?之三——Kalman滤波
  10. javascript(五)验证
  11. [iOS Animation]-CALayer 绘图效率
  12. 如何远程调试zookeeper集群
  13. 敏捷(Agile)——“说三道四”
  14. c++构造函数成员初始化中赋值和初始化列表两种方式的区别
  15. A1146. Topological Order
  16. android listView多层嵌套listView显示不全问题
  17. Docker进入容器后使用ifconfig等命令“command not found”解决办法
  18. SQL 加载
  19. 【转】Python中的字符串与字符编码
  20. Python Select模型(程序流程)(转)

热门文章

  1. Mybatis入门及Dao开发方式
  2. 【社区公益】送《Web前端开发最佳实践》给需要的人
  3. jenkins升级
  4. 几种JS&CSS框架
  5. 003 JTA的使用与理解
  6. A - Superset CodeForces - 97B(人生第一个分治法,感觉,像二分啊。。)
  7. 图形文件元数据管理工具exiv2
  8. 2018-2019-2 20162318《网络对抗技术》Exp4 恶意代码分析
  9. bzoj 1492
  10. Codeforces Round #293 (Div. 2) C. Anya and Smartphone 数学题