首先看一下效果
源码
使用
下载demo,拷贝GestureView文件夹到项目中
在ViewController中引用
#import "GestureView.h"
- 引用代理
@interface ViewController ()<GestureDelegate>
- 在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];
- 原密码为nil调用
//原密码为nil调用
- (void)GestureSetResult:(NSString *)result gestureView:(GestureView *)gestureView
{
NSLog(@"输入密码:%@",result);
[gestureView setRigthResult:result];
_label.text = @"请输入密码";
}
- 密码核对成功调用
//密码核对成功调用
- (void)GesturePasswordRight:(GestureView *)gestureView
{
NSLog(@"密码正确");
// _label.text = @"密码正确";
SecondViewController *svc = [[SecondViewController alloc]init];
[self presentViewController:svc animated:YES completion:nil];
}
- 密码核对失败调用
//密码核对失败调用
- (void)GesturePasswordWrong:(GestureView *)gestureView
{
NSLog(@"密码错误");
_label.text = @"密码错误";
[self performSelector:@selector(resetLabel) withObject:nil afterDelay:1];
}