用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动画模拟真实秒钟摆动效果的更多相关文章

  1. 用POP动画编写带富文本的自定义动画效果

    用POP动画编写带富文本的自定义动画效果 [源码] https://github.com/YouXianMing/UI-Component-Collection [效果] [特点] * 支持富文本 * ...

  2. 使用JavaScript和Canvas打造真实的雨滴效果

    使用JavaScript和Canvas打造真实的雨滴效果 寸志 · 1 年前 我最近搞了一个有趣的项目——rainyday.js .我认为这个项目并不怎么样,而且,事实上这是我第一次尝试接触一些比弹窗 ...

  3. 经典!HTML5 Canvas 模拟可撕裂布料效果

    这是一个模拟可撕裂布料效果的 HTML5 Canvas 应用演示,效果逼真.你会看到,借助 Canvas 的强大绘图和动画功能,只需很少的代码就能实现让您屏息凝神的效果. 温馨提示:为保证最佳的效果, ...

  4. iOS动画——弹窗动画(pop动画)

    用pop动画简单实现弹窗的缩放和渐变,感觉这个动画常用,就写一下博客 pop动画是Facebook推出的动画引擎,请自行到GitHub上搜索下载拖拽导入xcode项目中. 更多pop动画使用和原理可网 ...

  5. POP动画引擎中Layer与CALayer的一点区别

    POP动画引擎是facebook提供的一个开源框架, 可以实现很多的动画效果, 这里就不一一介绍啦, 有兴趣的童鞋请移步: https://github.com/facebook/pop 下面简单的讲 ...

  6. 基于Kinetic框架实现超酷的风铃悬挂摆动效果

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/iefreer/article/details/37049987 在踏得网开发过程中,我们在引导页面中 ...

  7. POP动画[1]

    POP动画[1] pop动画是facebook扩展CoreAnimation的,使用及其方便:) 1:Spring系列的弹簧效果(两个动画kPOPLayerBounds与kPOPLayerCorner ...

  8. POP动画[3]

    POP动画[3] 这一节主要讲解POP动画的自定义动画属性. POP动画中有一个参数,叫timingFunction,与CoreAnimation中的一个参数CAMediaTimingFunction ...

  9. POP动画[2]

    POP动画[2] 1:定制控制器间的转场动画. 源码有点多-_-!! // // RootViewController.h // Animation // // Copyright (c) 2014年 ...

随机推荐

  1. LeetCode-13. Roman to Integer(罗马数字转阿拉伯数字)

    1.题目描述 Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range f ...

  2. Path;Paths和Files;FileVisitor

    package filet; import java.io.FileOutputStream; import java.nio.file.FileStore; import java.nio.file ...

  3. Shell 编程-常见的文件处理命令

    touch 命令 touch命令用于创建空文件,例如有时应用程序希望在它们写入数据之前,某个日志文件就已经存在.这时可用touch命令创建一个空文件:touch test1:touch命令还可以用来改 ...

  4. iOS语音播报文字

    记得大学的时候学微软Window Phone时,有语音识别类似苹果的嘿,Siri.今天无聊百度搜了一下,搜到苹果语音播报文字.自己试了下还挺好玩. 1.引入框架#import <AVFounda ...

  5. PHP调用百度api生成短网址&根据短网址恢复长网址

    接口api文档地址:http://dwz.cn/#/apidoc?_k=i9ev5p 代码demo header("Content-type: text/html; charset=utf- ...

  6. 使用PowerShell创建SSAS Role

    PowerShell, SSAS, Role, DatabasePermission, Cube, Dimension, CubePermission, CubeDimensionCube 在SSAS ...

  7. Jquery Ajax 复杂json对象提交到WebService

    在ajax的已不请求中,常常返回json对象.可以利用json.net给我们提供的api达到快速开发. 例子: using System;using System.Collections;using ...

  8. [转] .NET出现频率非常高的笔试题

    又到了金三银四的跳槽季,许多朋友又开始跳槽了,这里我简单整理了一些出现频率比较高的.NET笔试题,希望对广大求职者有所帮助. 一..net基础 1.  a=10,b=15,请在不使用第三方变量的情况下 ...

  9. Java CountDownLatch解析(下)

    写在前面的话 在上一篇CountDownLatch解析中,我们了解了CountDownLatch的简介.CountDownLatch实用场景.CountDownLatch实现原理中的await()方法 ...

  10. linux ubuntu 安装nginx

    参考原文 在Ubuntu下安装Nginx有以下方法,但是如果想要安装最新版本的就必须下载源码包编译安装. 一.基于APT源安装 sudo apt-get install nginx 安装好的文件位置: ...