//指纹识别解锁的VC
#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
- (void)applicationWillEnterForeground:(UIApplication *)application {
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
KBTouchLoginController * VC = [[KBTouchLoginController alloc]init];
[cd.nowVC presentViewController:VC animated:YES completion:^{
}];
}