ShakingAlertView  震动效果的AlertView

https://github.com/lukestringer90/ShakingAlertView

ShakingAlertView is a UIAlertView subclass with a password entry textfield. Incorrect password entry causes a "shake" animation similar to the OS X account login screen.

这是一个UIAlertView的子类并带有一个密码输入的textfield。输入错误的密码会触发震动效果,与 OS X 登陆界面相似。

Installation

Cocoapods

用COcoapods安装:

Add to your Podfile:

pod 'ShakingAlertView'

Adding source code manually

Clone the git repo and drag the "src" folder into your project. This contains the UI components and cryptographic helpers necessary for hashing passwords.

将“src”文件夹拖入到工程当中。这个文件夹包含了UI显示组件以及给密码加密用的文件。

Usage

Plaintext password

Use ShakingAlertView just like UIAlertView. For a checking a plain text password:

你可以像使用UIAlertView那样子来使用ShakingAlertView。检查文本合法性参考如下:

ShakingAlertView *shakingAlert = nil;
shakingAlert = [[ShakingAlertView alloc] initWithAlertTitle:@"Enter Password"
checkForPassword:@"pass"]; [shakingAlert setOnCorrectPassword:^{
// Code to execute on correct password entry
}]; [shakingAlert setOnDismissalWithoutPassword:^{
// Code to execute on alert dismissal without password entry
}]; [shakingAlert show];

Rather than using a delegate, pass the instance a completion block to be executed for correct password entry and alert dismissal. ShakingAlertView uses ARC so no need to release your instances.

使用代理,或者传递一个block的实例变量来判断文本输入正确或者错误的执行入口。ShakingAlertView使用ARC所以不需要你来释放你的实例变量。

Hashed passwords

ShakingAlertView uses the Common Crypto C API to hash the entered text to SHA1 or MD5. Therefore if you only know the hashed counterpart of a password string you can specify this along with the hashing algorithm type in the constructor.

ShakingAlertView使用了通用C接口的SHA1或者MD5来加密文本。你可以指定某种加密方式来加密。

ShakingAlertView *shakingAlert = nil;
shakingAlert = [[ShakingAlertView alloc] initWithAlertTitle:@"Enter Password"
checkForPassword:@"W6ph5Mm5Pz8GgiULbPgzG37mj9g=" //sha1 hash of 'password'
usingHashingTechnique:HashTechniqueSHA1];

The hashing algorithm to use is defined by an enum and passed into the constructor.

加密算法用枚举值来标示。

typedef enum {
HashTechniqueNone,
HashTechniqueSHA1,
HashTechniqueMD5
} HashTechnique;

HashTechniqueNone is used if no technique is specified, like in the initWithAlertTitle:checkForPassword andinitWithAlertTitle:checkForPassword:onCorrectPassword:onDismissalWithoutPassword constructors. Here the entered string is compared with the specified plaintext password using a simple isEqualToString: evaluation.

如果是显示标题,那就使用HashTechniqueNone。

Running the tests

The ShakingAlertView class is tested using the BDD tool Kiwi. To run the tests install Kiwi via Cocoapods, and the open the workspace:

cd Example\ Project/
pod install
open ExampleProject.xcworkspace/

Make sure the "ShakingAlertView" scheme is selected then run the tests with ⌘+U

Acknowledgements

NSData+Base64.h/m and b64.h/m from aqtoolkit by Jim Dovey

Kiwi testing tool.

[翻译] 带有震动效果的 ShakingAlertView的更多相关文章

  1. 【温故而知新-Javascript】图片效果(图像震动效果、闪烁效果、自动切换图像)

    1.当鼠标指针经过图像时图像震动效果 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...

  2. jQuery实现的Div窗口震动效果实例

    本文实例讲述了jQuery实现的Div窗口震动效果.分享给大家供大家参考.具体如下: 这是一款jQuery窗口震动效果代码,在Div边框内点击一下鼠标,它就开始震动了,适用浏览器:IE8.360.Fi ...

  3. QT窗口渐现效果,窗口震动效果,鼠标移动窗口

    //窗口渐现效果void MainWindow::closeWindowAnimation() //关闭窗口效果 { QPropertyAnimation *animation = new QProp ...

  4. Unity3D相机震动效果

    在一些格斗.射击以及动作类游戏中 相机震动效果是十分重要的 一个平凡的镜头 在关键时刻加入相机震动后 便可以展现出碰撞.危险.打斗以及激动人心的效果 相机震动的实现方式有很多 但都会涉及摄像机位置的变 ...

  5. unity震动效果

    using System.Collections; using System.Collections.Generic; using UnityEngine; //思想:在短时间内在规定圆内随机震动对象 ...

  6. iOS 添加震动效果

    开发过程中,有时候会碰到点击按钮或者某个动画会配合震动效果:下面介绍iOS开发过程中的震动添加: 导入:#import <AudioToolbox/AudioToolbox.h> 在需要出 ...

  7. ListView 实现带有Filpper效果的左右滑动删除 Item

    ListView 实现带有Filpper效果的左右滑动删除 Item  的实现最基本的方法还是 对 Listview 的继承重写 .然后是在删除过程中加入 TranslateAnimation 滑动事 ...

  8. Swift 带有动画效果的TabBarItem

    额...貌似挺长时间没有总结新知识了,最近在看swift,之前swift刚出来的时候大体看了一遍,后来时间长了没看加之swift2.0做了比较大的调整,公司项目也不是用swift写的,也就没怎么看了, ...

  9. Android 为点击事件添加震动效果

    Android 点击Button 实现震动效果 学习自:网络 Overview 在Android 的点击效果中,遇到震动效果的还是很多的. 接下来就让我们看一下如何实现震动效果. 所需要的权限 如果我 ...

随机推荐

  1. GUC-14 ForkJoin

    import java.time.Duration; import java.time.Instant; import java.util.concurrent.ForkJoinPool; impor ...

  2. 【LOJ】#2432. 「POI2014」代理商 Couriers

    题解 建出一个主席树,因为出现大于区间一半的数只能有一个,就看看左右区间的增加有没有大于一半,如果有就走向那个子树,如果没有那么返回0 代码 #include <iostream> #in ...

  3. 【51nod】1123 X^A Mod B (任意模数的K次剩余)

    题解 K次剩余终极版!orz 写一下,WA一年,bug不花一分钱 在很久以前,我还认为,数论是一个重在思维,代码很短的东西 后来...我学了BSGS,学了EXBSGS,学了模质数的K次剩余--代码一个 ...

  4. 在windows下使用Cygwin模拟unix环境 并安装apt-cyg svn等插件

    在windows下使用Cygwin模拟unix环境,并安装apt-cyg,svn等工具 一.Cygwin的安装 1. 下载Cygwin,这个可以到这里下载 ,至于使用32位的还是64位的版本可以根据自 ...

  5. Ionic Js十八:滑动框

    ion-slide-box 滑动框是一个包含多页容器的组件,每页滑动或拖动切换: 效果图如下:   用法 <ion-slide-box on-slide-changed="slid ...

  6. 2017-2018-1 20179202《Linux内核原理与分析》第八周作业

    一 .可执行程序的装载 1. 预处理.编译.链接 gcc –e –o hello.cpp hello.c //预处理 gcc -x cpp-output -S -o hello.s hello.cpp ...

  7. 学习 HMM

    简介 HMM 中的变量可以分为两组. 第一组是状态变量 \(\{y_i,y_2,\cdots, y_n\}\), 其中 \(y_i \in \mathcal{Y}\) 表示第 \(i\) 时刻的系统状 ...

  8. Bomb HDU 3555 dp状态转移

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3555 题意: 给出一个正整数N,求出1~N中含有数字“49”的数的个数 思路: 采用数位dp的状态转移方程 ...

  9. Mac 上关于TFTP Server 软件的使用

    软件下载地址 http://ww2.unime.it/flr/tftpserver/ 软件下载后进行安装,打开软件, 如果出现如下图所示情况 然后当你点击蓝色的Fix 按钮时,如果又出现如下提示 这时 ...

  10. iOS Sprite Kit教程之使用帮助文档以及调试程序

    iOS Sprite Kit教程之使用帮助文档以及调试程序 IOS中使用帮助文档 在编写代码的时候,可能会遇到很多的方法.如果开发者对这些方法的功能,以及参数不是很了解,就可以使用帮助文档.那么帮助文 ...