Additive属性动画
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
细节

Additive属性动画的更多相关文章
- Android动画效果之Property Animation进阶(属性动画)
前言: 前面初步认识了Android的Property Animation(属性动画)Android动画效果之初识Property Animation(属性动画)(三),并且利用属性动画简单了补间动画 ...
- Android动画效果之初识Property Animation(属性动画)
前言: 前面两篇介绍了Android的Tween Animation(补间动画) Android动画效果之Tween Animation(补间动画).Frame Animation(逐帧动画)Andr ...
- Android属性动画
这几天看郭神的博客 Android属性动画完全解析(上),初识属性动画的基本用法之后,我自己突然想实现一种动画功能,就是我们在携程网.阿里旅行等等手机APP端买火车票的时候,看到有选择城市,那么就有出 ...
- Android动画:模拟开关按钮点击打开动画(属性动画之平移动画)
在Android里面,一些炫酷的动画确实是很吸引人的地方,让然看了就赏心悦目,一个好看的动画可能会提高用户对软件的使用率.另外说到动画,在Android里面支持3种动画: 逐帧动画(Frame Ani ...
- android 帧动画,补间动画,属性动画的简单总结
帧动画——FrameAnimation 将一系列图片有序播放,形成动画的效果.其本质是一个Drawable,是一系列图片的集合,本身可以当做一个图片一样使用 在Drawable文件夹下,创建ani ...
- View动画和属性动画
在应用中, 动画效果提升用户体验, 主要分为View动画和属性动画. View动画变换场景图片效果, 效果包括平移(translate), 缩放(scale), 旋转(rotate), 透明(alph ...
- Android属性动画源代码解析(超详细)
本文假定你已经对属性动画有了一定的了解,至少使用过属性动画.下面我们就从属性动画最简单的使用开始. ObjectAnimator .ofInt(target,propName,values[]) .s ...
- ObjectAnimator属性动画应用demo
感谢慕课网--eclipse_xu 布局文件:activity_main.xml <FrameLayout xmlns:android="http://schemas.android. ...
- 使用属性动画 — Property Animation
属性动画,就是通过控制对象中的属性值产生的动画.属性动画是目前最高级的2D动画系统. 在API Level 11中添加.Property Animation号称能控制一切对象的动画,包括可见的和不可见 ...
随机推荐
- hdu 3951 硬币围成一圈(博弈)
n个硬币围成一个环 每次只能取1-K个硬币 最后取完者胜 假如5个硬币 每次取1-2个情况1 先手取1个 后手取剩下4个中间2个 破坏了连续 虽然最后剩2个,但先手只能取一个 然后后再取一个 后手胜 ...
- 为django的python manage.py加自定义命令
计划在开发软件的过程中, 每次可以自己加入测试数据,这样就可以每次作全新的测试了. 将这个初始化django modules数据命令,将在manage.py里是最合适的. 下面我们就来实现吧. 参考文 ...
- winform框架源码-Devexpress开发框架
链接: https://pan.baidu.com/s/1TnDj6qftGEUl3sTB8QXs_w 提取码: 关注公众号[GitHubCN]回复获取 开发模式:C/S C/S采用的是dev14 ...
- Storm(一)Storm的简介与相关概念
一.Storm的简介 官网地址:http://storm.apache.org/ Storm是一个免费开源.分布式.高容错的实时计算系统.Storm令持续不断的流计算变得容易,弥补了Hadoop批处理 ...
- bzoj 3144
3144 思路: xxy: 代码: #include <cstdio> #include <cstring> #include <iostream> #includ ...
- javascript输入验证数字方法,适合充值时输入正整数验证
说明:用于验证正整数的输入,不允许输入其他字符. html: <input type="text" id="sell_jobNum" name=" ...
- 【51nod】1773 A国的贸易
题解 FWT板子题 可以发现 \(dp[i][u] = \sum_{i = 0}^{N - 1} dp[i - 1][u xor (2^i)] + dp[i - 1][u]\) 然后如果把异或提出来可 ...
- SHOW SLAVE STATUS解读
*************************** 1. row *************************** Slave_IO_State: ...
- 【基础知识】C#数据库中主键类型的选择
主键在数据库中占有很大的地位,对于表的关联性,和数据的唯一识别性有重要的作用: 1,在C#开发中,Int自增字段和Guid(数据库中是uniqueidentifier类型)可设置为主键: 1>G ...
- rabbit:Mnesia could not connect to any nodes
环境: rabbitmq集群 2台机器,挂了一台后重启服务,发现在服务启动不了错误如下: 这里rabbit连接不商rabbit02这里这个服务也无法启动 解决办法: rabbitmq默认的数据库位 ...