SCViewShaker

https://github.com/rFlex/SCViewShaker

About

A highly configurable UIView category for shaking a view. You start shaking your views with a one liner :). It supports a few different shaking styles (horizontal, vertical, rotate) and let you configure the duration, the speed and the shake strength.

一个关于view的category,可以高度定制.只需要一行代码就可以让你的view振动起来.它支持几种振动的样式,可以让你设置振动间隔时间,振动速度以及振动的强度.

Usage

SCViewShaker works as a category on UIView. It provides the following methods:

SCViewShaker以UIView的category的方式运行,提供了以下几个方法:

- (void)shake;

- (void)shakeWithOptions:(SCShakeOptions)shakeOptions force:(CGFloat)force duration:(CGFloat)duration iterationDuration:(CGFloat)iterationDuration completionHandler:(ShakeCompletionHandler)completionHandler

- (void)endShake

@property (readonly, nonatomic) BOOL isShaking

shake does a small shake on the view for a short amount of time. It was added as a convenience method.

shake方法会让view振动几次后就停止,是一个便利的方法.

shakeWithOptions:force:duration:iterationDuration:completionHandler: performs a new shake action with the complete control on how the shake will be done. It takes the follow parameters:

shakeWithOptions:force:duration:iterationDuration:completionHandler:执行了一系列的可以设置的振动的动作,它有着如下的一些参数:

shakeOptions is an enum of options that can be activated by using the OR operator (like SCShakeOptionsDirectionRotate | SCShakeOptionsForceInterpolationNone).

shakeOptions是一个枚举值选项,可以用或语句的方式组织参数.

force is the coefficient of force to apply on each shake iteration (typically between 0 and 1 even though nothing prevents you for setting a higher value if you want).

force是一个振动幅度的参数.

duration is the total duration of the shaking motion. This may be ignored depending of the options you set. iterationDuration is how long each shake iteration will last. You may want to set a very low value (like 0.02) if you want a proper shake effect.

duration是所有振动动作的间隔时间,这个参数有可能因为shakeOptions参数的设置而失效.iterationDuration表示的是每一个振动能持续的时间.你也许需要设置一个很小的值(如0.02)才能达到一种好的振动效果.

completionHandler, if not null, is the block that will be invoked when the shake finishes.

completionHandler,如果设置为null,这是一个block,在振动结束后会被调用.

Simple example

UIView *view = ...; // Grab a view from somewhere
[view beginShakingWithOptions:SCShakeOptionsDirectionRotate | SCShakeOptionsForceInterpolationExpDown | SCShakeOptionsAtEndRestart | SCShakeOptionsAutoreverse force:0.15 duration:1 iterationDuration:0.03 completionHandler:nil];

Options

Direction

The direction affects the visual effect of the shake effect. All value bounds shown here are based on a force of 1.

方向影响视觉上的振动效果.所有的参数都是基于强度1来计算的.

SCShakeOptionsDirectionRotate: The view will rotate from -90° to 90°. 这个view会从-90°到90°旋转

SCShakeOptionsDirectionHorizontal: The view will move horizontally from -frameWidth to +frameWidth. 这个view会从水平的-frameWidth值移动到+frameWidth值.

SCShakeOptionsDirectionVertical: The view will move vertically from -frameHeight to +frameHeight. 这个view会从垂直的-frameHeight值移动到+frameHeight值.

SCShakeOptionsDirectionHorizontalAndVertical: The view will randomly move horizontally or vertically. 这个view会随机的在水平或者垂直方向上移动.

Force interpolation

The force interpolation affects how the force changes in the time. 强度参数影响着每次改变的次数

SCShakeOptionsForceInterpolationNone: The force will remain always the same as the one you provided.

SCShakeOptionsForceInterpolationLinearUp: The force will linearly changes from 0 to the one you provided.

SCShakeOptionsForceInterpolationLinearDown: The force will linearly changes from the one you provided to zero.

SCShakeOptionsForceInterpolationExpUp: The force will exponentialy changes from 0 to the one you provided.

SCShakeOptionsForceInterpolationExpDown: The force will exponentialy changes from the one you provided to zero.

SCShakeOptionsForceInterpolationRandom: The force will randomly change between 0 and the one you provided.

Action at end

The action at end defines what should happen when the shake completes 定义了当振动结束之后的行为

SCShakeOptionsAtEndRestart: The shake will be restarted automatically from the beginning. 振动将会自动重新开始

SCShakeOptionsAtEndComplete: The shake will stop. 振动将会停止

SCShakeOptionsAtEndContinue: The shake will contnue endlessly. The force won't change anymore when it reaches the duration. 振动将不会停止,强度参数不会对他产生任何作用了

Misc options

SCShakeOptionsAutoreverse: When the shake reaches the end, the shake will continue in the reverse order. Setting this value will double the effective duration. 当振动结束后,这个振动将会逆序在执行一遍,设置这个参数会让振动时间变成双倍.

[翻译] SCViewShaker的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. Java虚拟机(四):JVM类加载机制

    1.什么是类的加载 类的加载指的是将类的.class文件中的二进制数据读入到内存中,将其放在运行时数据区的方法区内,然后在堆区创建一个java.lang.Class对象,用来封装类在方法区内的数据结构 ...

  2. Java 生成指定范围的随机数

    /** * 生成[min, max]之间的随机整数 * * @param min 最小整数 * @param max 最大整数 * @return * @author jqlin */ private ...

  3. redis-手写redis切片和非切片连接池并注入springboot中

    spring-data整合了redispool, 并提供redisTemplate使用, 但有时需要用到shradedJedisPool, 就需要手动注入了 手写redispool并注入springb ...

  4. win10装系统--笔记

    U盘安装WIN10时显示 windows无法安装到这个磁盘 选中的磁盘采用GPT分区形式 一.原因分析 win8/win10系统均添加快速启动功能,预装的win8/win10电脑默认都是UEFI引导和 ...

  5. 体验 QQ机器人C# SDK 1.X 特性总结

    主要特性 依赖注入 框架本身采用 Autofac 作为依赖注入框架.进行插件开发时,必然会使用到该框架.建议开发者阅读官方文档熟悉其用法.https://autofac.readthedocs.io/ ...

  6. Week6&7——第一次项目冲刺(Alpha版本)

    Deadline: 2017-11-11 10:00PM,以博客发表日期为准. 评分基准: 按时交 - 有分(需求&原型改进与系统设计-10分,敏捷冲刺-70分),检查的项目包括后文的三个方面 ...

  7. POJ 1251 Jungle Roads(Kruskal算法求解MST)

    题目: The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money w ...

  8. C#神奇的扩展方法

      以前总听说扩展方法扩展方法,只是听说是C#3.0后出来的新玩意,也仅仅是知道Linq中用到好多的扩展方法,但是他究竟是个什么东东,怎么用它,用它的好处是什么,总是模模糊糊,那么我们今天就尝试揭开它 ...

  9. [javaSE] 网络编程(TCP,UDP,Socket特点)

    UDP特点: 面向无连接,把数据打包发过去,收不收得到我不管 数据大小有限制,一次不能超过64k,可以分成多个包 这是个不可靠的协议 速度很快 视频直播,凌波客户端,feiQ都是UDP协议 TCP特点 ...

  10. MyBatis 常用写法

    MyBatis 常用写法 1.forEach 循环   forEach 元素的属性主要有 item, idnex, collection, open, separator, close. collec ...