以前App上使用手势密码很常见,后来因为有指纹解锁了,这货就慢慢淡出了江湖。
这是很早以前写下的东西了,想想还是把它发出来吧,供有缘人参考一下。
简单使用
@interface ViewController () <JXGesturePasswordViewDelegate>
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
JXGesturePasswordView *gesturePasswordView = [[JXGesturePasswordView alloc] init];
gesturePasswordView.center = self.view.center;
gesturePasswordView.delegate = self;
[self.view addSubview:gesturePasswordView];
}
- (void)gesturePasswordView:(JXGesturePasswordView *)gesturePasswordView didFinishDrawPassword:(NSString *)password
{
// 在导航标题显示轨迹
self.title = password;
// 校验密码
NSString *successPassword = @"1478";
NSString *message = nil;
if (![successPassword isEqualToString:password])
{
[gesturePasswordView showError];
message = [NSString stringWithFormat:@"错误!请依次连接%@", successPassword];
}
else
{
message = @"正确!";
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:message delegate:nil cancelButtonTitle:@"好的" otherButtonTitles:nil];
[alert show];
});
}
项目源码:GesturePassword