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号称能控制一切对象的动画,包括可见的和不可见 ...
随机推荐
- 实现nlp文本生成中的beam search解码器
自然语言处理任务,比如caption generation(图片描述文本生成).机器翻译中,都需要进行词或者字符序列的生成.常见于seq2seq模型或者RNNLM模型中. 这篇博文主要介绍文本生成解码 ...
- Ionic入门三:列表
列表是一个应用广泛的界面元素,在所有移动app中几乎都会使用到. 列表可以是基本文字.按钮,开关,图标和缩略图等. 列表项可以是任何的HTML元素.容器元素需要list类,每个列表项需要使用item类 ...
- Git 简史
同生活中的许多伟大事件一样,Git 诞生于一个极富纷争大举创新的年代.Linux 内核开源项目有着为数众广的参与者.绝大多数的 Linux 内核维护工作都花在了提交补丁和保存归档的繁琐事务上(1991 ...
- CentOS 7下MySQL5.7.23的服务配置参数测试
CentOS 7默认安装MySQL5.7.23,服务管理发生了变化,从sysvinit(service mysql start)变化为systemd(systemctl start mysqld.se ...
- 加密grub防止通过单用户模式破解root密码
(1).CentOS6 1)产生加密密码 [root@CentOS6 ~]# grub-md5-crypt Password: Retype password: $1$QPduF0$FNhzDUPQP ...
- Mybatis框架简单使用
Mybatis框架简单使用 环境搭建 新建一个JavaWeb项目,在web\WEB-INF\创建lib文件,并且在其下添加Mybatis的核心包以及依赖包,以及Mysql驱动包,junit4测试包等. ...
- gdg shell
export TIMESTAMP=`date +%Y%m%d_%H%M%S`GDGFILE=file1_${TIMESTAMP}.txtsuffix=${GDGFILE#*_}prefix=${suf ...
- .Net中的IO
C#中的IO 本文环境为: Win 10 VS 2015 .net Framework 版本 4.0 File 类 File 类是一个工具类,可以用来判断文件是否存在和方便的创建文件, 读取.写入等操 ...
- BZOJ1878: [SDOI2009]HH的项链[树状数组+离线 | 主席树]
题意: 询问区间不同种类颜色数 [2016-11-15] 离线好厉害 对于每一个区间询问,一个数只考虑一次,那么考虑他最后出现的一次 将询问按r排序 从1到n扫描,用树状数组维护一个位置应不应该考虑( ...
- BZOJ.3489.A simple rmq problem(主席树 Heap)
题目链接 当时没用markdown写,可能看起来比较难受...可以复制到别的地方看比如DevC++. \(Description\) 给定一个长为n的序列,多次询问[l,r]中最大的只出现一次的数.强 ...