[翻译] 带有震动效果的 ShakingAlertView

简介:

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.

 

 

 

 

目录
相关文章
|
1月前
|
人工智能 自然语言处理 数据可视化
比Sora更王炸,LTX Studio文本生成超25秒,视频自带背景音乐、转场等效果!
【2月更文挑战第13天】比Sora更王炸,LTX Studio文本生成超25秒,视频自带背景音乐、转场等效果!
73 3
比Sora更王炸,LTX Studio文本生成超25秒,视频自带背景音乐、转场等效果!
|
4月前
|
算法
音频作曲算法大全
音频作曲算法大全
25 0
|
10月前
|
人工智能 JSON 安全
能听懂语音的ChatGPT来了:10小时录音扔进去,想问什么问什么
能听懂语音的ChatGPT来了:10小时录音扔进去,想问什么问什么
103 0
|
11月前
|
API 语音技术 Python
轻声低语,藏在光芒下的语音转文字模型Whisper
轻声低语,藏在光芒下的语音转文字模型Whisper
1063 0
|
Linux 语音技术 开发工具
巧用讯飞TTS进行文本合成语音(LINUX操作系统)
如果执行demo程序tts_offline_sample失败,那么请看下是否将libmsc.so有没有加载到ldconfig中。如果没有,则将libmsc.so放到/usr/lib64下,然后用root
巧用讯飞TTS进行文本合成语音(LINUX操作系统)
|
机器学习/深度学习 人工智能 自然语言处理
高保真音色媲美真人,StyleTTS为QQ浏览器「听书」语音注入情感
QQ 浏览器「听书」背后的 StyleTTS 让合成语音有了情感的温度。
232 0
高保真音色媲美真人,StyleTTS为QQ浏览器「听书」语音注入情感
|
机器学习/深度学习 人工智能 自然语言处理
现实版「柯南变声器」来了,搜狗变声让你声音随心变
声音秒变志玲姐姐,秒变「矮大紧」,秒变萝莉、正太,现在通通不是问题!
599 0
现实版「柯南变声器」来了,搜狗变声让你声音随心变
|
传感器 机器学习/深度学习 算法
“会说话”的手!这个手套可以翻译手语,还能通过APP转换语音
“会说话”的手!这个手套可以翻译手语,还能通过APP转换语音
255 0
几个鸟叫的声音
http://files.cnblogs.com/jyk/111.rar
644 0