iOS 手勢密碼鎖

首先看一下效果

手勢密碼鎖.gif

源碼

源碼Demo獲取方法

關注 【網羅開發】微信公衆號,回覆【90】即可領取。 網羅天下方法,方便你我開發,全部文檔會持續更新,歡迎關注一塊兒成長!bash

使用

  1. 下載demo,拷貝GestureView文件夾到項目中微信

  2. 在ViewController中引用ui

#import "GestureView.h"
複製代碼
  1. 引用代理
@interface ViewController ()<GestureDelegate>
複製代碼
  1. 在viewDidLoad中初始化GestureView
GestureView *gesView = [[GestureView alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-self.view.frame.size.width-60, self.view.frame.size.width, self.view.frame.size.width)];
    gesView.delegate = self;
    [self.view addSubview:gesView];
複製代碼
  1. 原密碼爲nil調用
//原密碼爲nil調用
- (void)GestureSetResult:(NSString *)result gestureView:(GestureView *)gestureView
{
    NSLog(@"輸入密碼:%@",result);
    [gestureView setRigthResult:result];
    _label.text = @"請輸入密碼";
}
複製代碼
  1. 密碼覈對成功調用
//密碼覈對成功調用
- (void)GesturePasswordRight:(GestureView *)gestureView
{
    NSLog(@"密碼正確");
    //    _label.text = @"密碼正確";
    
    SecondViewController *svc = [[SecondViewController alloc]init];
    
    [self presentViewController:svc animated:YES completion:nil];
    
}
複製代碼
  1. 密碼覈對失敗調用
//密碼覈對失敗調用
- (void)GesturePasswordWrong:(GestureView *)gestureView
{
    NSLog(@"密碼錯誤");
    _label.text = @"密碼錯誤";
    [self performSelector:@selector(resetLabel) withObject:nil afterDelay:1];
}
複製代碼
相關文章
相關標籤/搜索