iOS 指纹解锁

//指纹识别解锁的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





 appdelegete  使用 

- (void)applicationWillEnterForeground:(UIApplication *)application {     


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions


 KBTouchLoginController * VC = [[KBTouchLoginController alloc]init];

            

            [cd.nowVC presentViewController:VC animated:YES completion:^{

                

            }];

        }




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值