iOS 指纹解锁
2015-08-26 17:48
561 查看
//指纹识别解锁的VC
#import <UIKit/UIKit.h>
@interface KBTouchLoginController :
UIViewController
@end
实现文件
appdelegete 使用
- (void)applicationWillEnterForeground:(UIApplication *)application {
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
KBTouchLoginController * VC = [[KBTouchLoginController
alloc]init];
[cd.nowVC
presentViewController:VC animated:YES
completion:^{
}];
}
#import <UIKit/UIKit.h>
@interface KBTouchLoginController :
UIViewController
@end
实现文件
// // KBTouchLoginController.m // kabao // // Created by wxb on 15/6/30. // Copyright (c) 2015年 shengyun. All rights reserved. // #import "KBTouchLoginController.h" #import "KBLoginViewController.h" #import <LocalAuthentication/LocalAuthentication.h> @interface KBTouchLoginController () @property (weak, nonatomic) IBOutlet UIImageView *head; @property (weak, nonatomic) IBOutlet UIButton *loginBtn; @end @implementation KBTouchLoginController - (void)viewDidLoad { [super viewDidLoad]; self.head.layer.cornerRadius = 40; self.head.layer.masksToBounds = YES; self.loginBtn.titleLabel.font = [UIFont fontWithName:FONTNAME size:15]; // Do any additional setup after loading the view from its nib. } -(void)viewDidAppear:(BOOL)animated{ LAContext * la = [[LAContext alloc]init]; BOOL TouchSwitch = [la canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil]; if (TouchSwitch) { [la evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"需要验证您的指纹来确认您的身份信息" reply:^(BOOL success, NSError *error) { if (success) { [self performSelectorOnMainThread:@selector(successful) withObject:nil waitUntilDone:NO]; }else{ [self performSelectorOnMainThread:@selector(failed) withObject:nil waitUntilDone:NO]; } }]; } } -(void)successful{ [self dismissViewControllerAnimated:YES completion:^{ }]; } -(void)failed{ UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"指纹验证未通过" message:nil delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert show]; } - (IBAction)loginClick:(id)sender { KBLoginViewController * VC = [[KBLoginViewController alloc]init]; VC.changeStr = [[User createUser] usermobile]; VC.needBack = YES; VC.type = KBLoginBackTypeDismiss; UIImage * image = [UIImage imageNamed:@"title_BG"]; UIImage * image2 = [image resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, image.size.height, image.size.width)]; UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:VC]; [nav.navigationBar setBackgroundImage:image2 forBarMetrics:UIBarMetricsDefault]; [nav.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,[UIFont fontWithName:FONTNAME size:17],NSFontAttributeName, nil]]; CATransition *animation = [CATransition animation]; [animation setDuration:0.5]; [animation setType:kCATransitionPush]; [animation setSubtype:kCATransitionFromRight]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; [[self.view.window layer] addAnimation:animation forKey:@"SwitchToView"]; [self presentViewController:nav animated:NO completion:^{ }]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end
appdelegete 使用
- (void)applicationWillEnterForeground:(UIApplication *)application {
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
KBTouchLoginController * VC = [[KBTouchLoginController
alloc]init];
[cd.nowVC
presentViewController:VC animated:YES
completion:^{
}];
}
相关文章推荐
- 【iOS开发系列】MD5加密
- iOS开发系列--通知与消息机制
- iOS 多个tabBar之间跳转的问题
- iOS 二维码扫面 相册图片二维码读取和二维码的生成
- iOS项目引用静态库文件.a
- iOS第三方地图-百度地图定位的封装
- iOS 使用xib后获取view的frame出错的问题
- ios 常用的一些终端命令行
- iOS APNs问题
- iOS中通知和代理的区别
- iOS-NSUserDefaults的用法(轻量级本地数据存储)
- IOS学习第七篇 ——Protocol协议
- iOS 9 学习系列:MapKit 的新变化(Flyover、交通和自定义)
- ios 设置状态栏风格
- 解决港版A1530 ios8 联通4G 电话打不进无法接通的问题,联通4G开关开启方法
- Nagios upgrade 3.x to 4.x 升级
- IOS NSUserDefaults 的用法
- [转]iOS技巧之获取本机通讯录中的内容,解析通讯录源代码
- iOS 万能跳转界面方法 (runtime实用篇一)
- 【iOS】配置和使用静态库