CASpringAnimation的使用
CASpringAnimation的使用

效果

源码
https://github.com/YouXianMing/Animations
//
// CASpringAnimationController.m
// Animations
//
// Created by YouXianMing on 16/1/19.
// Copyright © 2016年 YouXianMing. All rights reserved.
// #import "CASpringAnimationController.h"
#import "RangeValueView.h"
#import "WxHxD.h"
#import "UIView+SetRect.h" @interface CASpringAnimationController () @property (nonatomic, strong) UIButton *showView; @property (nonatomic, strong) RangeValueView *stiffnessView;
@property (nonatomic, strong) RangeValueView *dampingView;
@property (nonatomic, strong) RangeValueView *massView;
@property (nonatomic, strong) RangeValueView *initialVelocityView; @end @implementation CASpringAnimationController - (void)setup { [super setup]; [self initRangeViews]; [self initButton];
} - (void)initButton { CGFloat gap = Height - - * - ; CGFloat width = .f;
self.showView = [[UIButton alloc] initWithFrame:CGRectMake(, , width, width)];
self.showView.center = CGPointMake(self.contentView.middleX, + gap / .f);
self.showView.backgroundColor = [UIColor cyanColor];
self.showView.layer.cornerRadius = width / .f;
self.showView.x = Width / .f - ;
[self.showView addTarget:self action:@selector(doAnimation) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.showView];
} - (void)doAnimation { CASpringAnimation *springAnimation = [CASpringAnimation animationWithKeyPath:@"position.x"];
springAnimation.stiffness = self.stiffnessView.currentValue;
springAnimation.mass = self.massView.currentValue;
springAnimation.damping = self.dampingView.currentValue;
springAnimation.initialVelocity = self.initialVelocityView.currentValue;
springAnimation.duration = springAnimation.settlingDuration; springAnimation.fromValue = @(Width / .f - );
springAnimation.toValue = @(Width / .f + );
self.showView.layer.position = CGPointMake(Width / .f + , self.showView.layer.position.y); [self.showView.layer addAnimation:springAnimation forKey:nil];
} - (void)initRangeViews { self.stiffnessView = [RangeValueView rangeValueViewWithFrame:CGRectMake(, Height - , Width - , )
name:@"硬度 Stiffness"
minValue:.f
maxValue:.f
defaultValue:.f];
[self.contentView addSubview:self.stiffnessView]; self.dampingView = [RangeValueView rangeValueViewWithFrame:CGRectMake(, Height - - , Width - , )
name:@"阻尼 Damping"
minValue:0.1f
maxValue:.f
defaultValue:.f];
[self.contentView addSubview:self.dampingView]; self.massView = [RangeValueView rangeValueViewWithFrame:CGRectMake(, Height - - *, Width - , )
name:@"质量 Mass"
minValue:0.1
maxValue:.f
defaultValue:.f];
[self.contentView addSubview:self.massView]; self.initialVelocityView = [RangeValueView rangeValueViewWithFrame:CGRectMake(, Height - - *, Width - , )
name:@"速度 Velocity"
minValue:-.f
maxValue:.f
defaultValue:.f];
[self.contentView addSubview:self.initialVelocityView];
} @end
细节

CASpringAnimation的使用的更多相关文章
- CASpringAnimation
iOS9新出现的 /** Subclass for mass-spring animations. */ @interface CASpringAnimation : CABasicAnimation ...
- iOS9 CASpringAnimation 弹簧动画详解
http://blog.csdn.net/zhao18933/article/details/47110469 1. CASpringAnimation iOS9才引入的动画类,它继承于CABaseA ...
- iOS进阶_动画的多种实现方式
一.UIView动画 //UIView动画有开始beginAnimation,有结束commitAnimation //第一步:开始UIView动画 [UIView beginAnimat ...
- CoreAnimation方法汇总
使用CoreAnimation一般分为三个部分:1.创建执行动画的CALayer 2.创建动画 3.CALayer 添加Animation CoreAnimation是以锚点为基础. CoreAnim ...
- 【原】iOS学习44之动画
1. 简单动画 1> UIImageView GIF 动画 GIF图的原理是:获取图片,存储在图片数组中,按照图片数组的顺序将图片以一定的速度播放 UIImageView *showGifima ...
- CoreAnimation动画(CALayer动画)
#pragma mark - CABasicAnimation动画 - (IBAction)basicAnimation:(UIButton *)sender { // 1.创建动画对象 CABasi ...
- github上所有大于800 star OC框架
https://github.com/XCGit/awesome-objc-frameworks#awesome-objc-frameworks awesome-objc-frameworks ID ...
- UI进阶 动画
前言:所谓动画,即应用界面上展示的各种过渡效果,不过其实没有动画并不影响我们产品的功能实现 一.动画 1.动画可以达到的效果 传达状态 提高用户对直接操作的感知 帮助用户可视化操作的结果 2.使用动画 ...
- iOS开发——图形编程OC篇&粘性动画以及果冻效果
粘性动画以及果冻效果 在最近做个一个自定义PageControl——KYAnimatedPageControl中,我实现了CALayer的形变动画以及CALayer的弹性动画,效果先过目: 先做个提纲 ...
随机推荐
- servlet 学习笔记(三)
同一用户的不同页面共享数据有以下四种方法: 1.sendRedirect()跳转 2.session技术 3.隐藏表单提交(form) 4. cookie技术(小甜饼) --------------- ...
- day6面向对象
面向对象介绍(http://www.cnblogs.com/alex3714/articles/5188179.htm) 世界万物,皆可分类 世界万物,皆为对象 只要是对象,就 ...
- day6 shelve模块
shelve模块 shelve模块是一个简单的k,v将内存数据通过文件持久化的模块,可以持久化任何pickle可支持的python数据格式,shelve模块是对pickle模块的补充.我们知道 ...
- HashMap 在 Java1.7 与 1.8 中的区别
hashMap 数据结构 如上图所示,JDK7之前hashmap又叫散列链表:基于一个数组以及多个链表的实现,hash值冲突的时候,就将对应节点以链表的形式存储. JDK8中,当同一个hash值(Ta ...
- MongoDB入门教程二[MongoDB Shell 简介与使用]
MongoDB Shell 是MongoDB自带的JavaScript Shell,随MongoDB一同发布,它是MonoDB客户端工具,可以在Shell中使用命令与MongoDB实例交互,对数据库的 ...
- 搭建 Android 集成开发环境
在搭建 Android 集成开发环境之前,我想说的是,我们学习的目标是同时掌握移动开发三种方式:iOS开发.Android开发和Html5手机网页开发.由于iOS的开发工具是采用苹果官方的XCode, ...
- Java 中线程安全问题
不好意思,一个国庆假期给我放的都不知道东西南北了,放松,很放松,差一点就弃更了,感谢那些催更的小伙伴们! 虽然没有更新,但是日常的学习还是有的,以后我尽量给大家分享一些通用知识,非技术. 但是本期还是 ...
- 【SQL】182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
- 支撑大规模公有云的Kubernetes改进与优化 (1)
Kubernetes是设计用来实施私有容器云的,然而容器作为公有云,同样需要一个管理平台,在Swarm,Mesos,Kubernetes中,基于Kubernetes已经逐渐成为容器编排的最热最主流的平 ...
- [ 转载 ] Java基础12--基础学习总结——数组
java基础学习总结——数组 一.数组的基本概念 数组可以看成是多个相同类型数据组合,对这些数据的统一管理. 数组变量属引用类型,数组也可以看成是对象,数组中的每个元素相当于该对象的成员变量. 数组的 ...