用POP动画模拟真实秒钟摆动效果
用POP动画模拟真实秒钟摆动效果

静态图:

动画图:

此处用到了POP中的Spring系列动画,现提供源码如下:
SecondClockView.h 与 SecondClockView.m
//
// SecondClockView.h
// YouXianMingClock
//
// Created by YouXianMing on 14-10-12.
// Copyright (c) 2014年 YouXianMing. All rights reserved.
// #import <UIKit/UIKit.h> @interface SecondClockView : UIView /**
* Use in conjunction with 'springSpeed' to change animation effect. Values are converted into corresponding dynamics constants. Defined as a value in the range [0, 20]. Defaults to 18.
*/
@property (nonatomic, assign) CGFloat springBounciness; /**
* The mass used in the dynamics simulation.
*/
@property (nonatomic, assign) CGFloat dynamicsMass; /**
* Use in conjunction with 'springBounciness' to change animation effect. Values are converted into corresponding dynamics constants. Defined as a value in the range [0, 20]. Defaults to 18.
*/
@property (nonatomic, assign) CGFloat springSpeed; /**
* 给与时间进行的动画
*
* @param second 当前秒
*/
- (void)startAnimationWithSecond:(float)second; @end
//
// SecondClockView.m
// YouXianMingClock
//
// Created by YouXianMing on 14-10-12.
// Copyright (c) 2014年 YouXianMing. All rights reserved.
// #import "SecondClockView.h"
#import "POP.h" /**
* 将角度转换为弧度
*
* @param d 角度
*
* @return 弧度
*/
#define DEGREES__TO__RADIANS(d) ((d) * M_PI / 180.f) @interface SecondClockView () { BOOL firstTime; } @end @implementation SecondClockView - (void)startAnimationWithSecond:(float)second
{
// 秒钟
POPSpringAnimation *springAnimation = \
[POPSpringAnimation animationWithPropertyNamed:kPOPLayerRotation]; springAnimation.fromValue = @(DEGREES__TO__RADIANS(()/.f)*(second - ) + DEGREES__TO__RADIANS(-));
if (firstTime == NO) {
firstTime = YES;
springAnimation.fromValue = @();
}
springAnimation.toValue = @(DEGREES__TO__RADIANS(()/.f)*second + DEGREES__TO__RADIANS(-));
springAnimation.springBounciness = (_springBounciness > && _springBounciness <= )?_springBounciness:.f;
springAnimation.dynamicsMass = (_dynamicsMass > )?_dynamicsMass:1.5f;
springAnimation.springSpeed = (_springSpeed > && _springSpeed <= )?_springSpeed:.f;
[self.layer pop_addAnimation:springAnimation forKey:nil];
} @end
使用时候的情形

使用的时候请引入POP库

用POP动画模拟真实秒钟摆动效果的更多相关文章
- 用POP动画编写带富文本的自定义动画效果
用POP动画编写带富文本的自定义动画效果 [源码] https://github.com/YouXianMing/UI-Component-Collection [效果] [特点] * 支持富文本 * ...
- 使用JavaScript和Canvas打造真实的雨滴效果
使用JavaScript和Canvas打造真实的雨滴效果 寸志 · 1 年前 我最近搞了一个有趣的项目——rainyday.js .我认为这个项目并不怎么样,而且,事实上这是我第一次尝试接触一些比弹窗 ...
- 经典!HTML5 Canvas 模拟可撕裂布料效果
这是一个模拟可撕裂布料效果的 HTML5 Canvas 应用演示,效果逼真.你会看到,借助 Canvas 的强大绘图和动画功能,只需很少的代码就能实现让您屏息凝神的效果. 温馨提示:为保证最佳的效果, ...
- iOS动画——弹窗动画(pop动画)
用pop动画简单实现弹窗的缩放和渐变,感觉这个动画常用,就写一下博客 pop动画是Facebook推出的动画引擎,请自行到GitHub上搜索下载拖拽导入xcode项目中. 更多pop动画使用和原理可网 ...
- POP动画引擎中Layer与CALayer的一点区别
POP动画引擎是facebook提供的一个开源框架, 可以实现很多的动画效果, 这里就不一一介绍啦, 有兴趣的童鞋请移步: https://github.com/facebook/pop 下面简单的讲 ...
- 基于Kinetic框架实现超酷的风铃悬挂摆动效果
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/iefreer/article/details/37049987 在踏得网开发过程中,我们在引导页面中 ...
- POP动画[1]
POP动画[1] pop动画是facebook扩展CoreAnimation的,使用及其方便:) 1:Spring系列的弹簧效果(两个动画kPOPLayerBounds与kPOPLayerCorner ...
- POP动画[3]
POP动画[3] 这一节主要讲解POP动画的自定义动画属性. POP动画中有一个参数,叫timingFunction,与CoreAnimation中的一个参数CAMediaTimingFunction ...
- POP动画[2]
POP动画[2] 1:定制控制器间的转场动画. 源码有点多-_-!! // // RootViewController.h // Animation // // Copyright (c) 2014年 ...
随机推荐
- 当spring抛出异常时出现的页面的@ExceptionHandler(RuntimeException.class) 用法
当spring抛出异常时出现的页面的@ExceptionHandler(RuntimeException.class) 用法 主要用在Controller层 @ExceptionHandler(Run ...
- thinkPHP5配置nginx环境无法打开(require(): open_basedir restriction in effect. File(/mnt/hgfs/root/tp5/thinkphp/start.php) is not within the allowed path(s)
今天想把玩一下tp5,结果怎么都无法访问,每次都是报500错误,我把错误提示都打开看到下面的错误 require(): open_basedir restriction in effect. File ...
- android常用Linux命令
安卓下面有个软件叫终端模拟器,其实就是Linux下的命令行,使用这些命令能有效处理问题. 1.基本知识 “/”,这个英文字母斜杠指的是根目录,类似Windows的C:\,但是Linux下只有一个根目录 ...
- WindowsServer2008安装IIS相关服务
控制面板->程序->打开或关闭Windows功能 添加角色,选择IIS服务器,选择以下角色服务,如果添加过就选择添加角色服务 如果出现500错误,这个跟程序没有多大关系,可以试一下以下操作 ...
- java多线程---------java.util.concurrent并发包----------ThreadPoolExecutor
ThreadPoolExecutor线程池 一.三个构造方法 ThreadPoolExecutor(int corePoolSize,int MaxmumPoolSize,long KeepAlive ...
- Upgrading WebLogic Application Environments --官方文档
http://docs.oracle.com/cd/E13179_01/common/docs92/upgrade/dirstruct.html WebLogic Domain Directory S ...
- java并发编程(5)并发程序测试
并发程序测试 一.正确性测试 如:对一个自定义缓存的测试 //自定义的缓存 public class SemaphoreBoundedBuffer <E> { private final ...
- Java基础教程(6)--数组
1.基本概念 数组中的每一项称为元素,每个元素都通过数字索引(也可以称为下标)访问,编号从0开始.例如,第4个元素的索引为3.下面的程序创建了一个int类型的数组,把一些值放入数组中并将每个值打印 ...
- Spring系列之——使用模板快速搭建springboot项目
1 在官网https://start.spring.io/生成spring boot的模板 2 IDEA导入模板,设置如下勾选项,其他选项卡为默认值 3 idea呈现 4 新增controller类 ...
- 学习Golang的步骤建议
一.快速入门 通过快速入门可以宏观的了解Go相关知识.快速入门可以去学习 go-tour 国内可以访问的中文版的 go-tour 地址有下面一些: http://gotour.qizhanming.c ...