iOS用笑臉密碼強度顯示:KMMSmileyStrength

jopen 11年前發布 | 17K 次閱讀 iOS開發 移動開發 KMMSmileyStrength

KMMSmileyStrength用于在iOS應用中用笑臉密碼強度顯示。

Preview

iOS用笑臉密碼強度顯示:KMMSmileyStrength iOS用笑臉密碼強度顯示:KMMSmileyStrength

特性

A password strength view that uses smiley faces to depict the strength of a password.

  • Set a custom font colour for the smiley faces, so that you can style it according to your app.
  • Set a custom font size

Installation

Cocoapods (Recommended)

  1. Add pod 'KMMSmileyStrength' to your Podfile.
  2. Run pod install

Then add flaticon.ttf to the project's info.plist under Fonts provided by application

Requirements

  • iOS 7.0 and greater
  • ARC

Examples

Code:

- (void)viewDidLoad {
    [super viewDidLoad];

    //Create the password strength view
    CGRect frame = CGRectMake(0, 0, CGRectGetHeight(self.passwordTextField.frame), CGRectGetHeight(self.passwordTextField.frame));
    self.smileyStrength = [[KMMSmileyStrength alloc] initWithFrame:frame];
    //Set it as the text field's right view
    self.passwordTextField.rightView = self.smileyStrength;
    self.passwordTextField.rightViewMode = UITextFieldViewModeNever;
}

/**
 *  Called when the text field's editing changed
 *
 *  @param sender the UITextField for the password
 */
-(IBAction)textDidChange:(id)sender {
    UITextField *textfield = sender;
    if(textfield.text.length > 0) {
        [self.smileyStrength evaluatePassword:textfield.text];
        self.passwordTextField.rightViewMode = UITextFieldViewModeAlways;
    } else {
        self.passwordTextField.rightViewMode = UITextFieldViewModeNever;
    }
}

項目主頁:http://www.baiduhome.net/lib/view/home/1418872180261

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!