Fingerprint unlock and custom transition animations

Source: Internet
Author: User

These two days work not busy, went to study the next fingerprint unlock and transition animation, in fact, the only one animation can say half a day, but today do not say animation. I have time to talk about this later.

Fingerprint unlocking, very simple, the official document is very clear, in fact, we have to do almost nothing.

1. Import #import <LocalAuthentication/LocalAuthentication.h> this framework

2, import the following code, fingerprint unlock is complete, so easy!!!! And then realize your big logic on it.

Lacontext *mycontext = [[Lacontext alloc]init];        Mycontext.localizedfallbacktitle = @ "Forgot password";    Nserror *error = nil; NSString *mylocalizedreasonstring = @ "Please enter fingerprint";
Determine if the fingerprint unlock function is supported if ([Mycontext canevaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics Error:&error]) {//support fingerprint unlock [mycontext evaluatepolicy:lapolicydeviceownerauthenticationwithbiometrics Localizedreason:mylocalizedreasonstring reply:^ (BOOL success, Nserror *error) { if (success) { Success [Self showalerview:@ "verified success"]; } else {//failed [Self showalerview:@ "validation failed"]; NSLog (@ "did not authenticate successfully"); } }]; } else {//Fingerprint unlock NSLog (@ "Could not evaluate policy"); [Self showalerview:@ "]; }

  

The fingerprint is unlocked and the next step is to customize the transition animation

1, the implementation of Uinavigationcontrollerdelegate in Viewcontrol the following method

-(Nullable ID <UIViewControllerAnimatedTransitioning>) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller                                            animationcontrollerforoperation: (uinavigationcontrolleroperation) Operation                                                         Fromviewcontroller: (Uiviewcontroller *) Fromvc                                                           toviewcontroller: (Uiviewcontroller *) ToVC  Ns_available_ios (7_0) {        if (operation = = Uinavigationcontrolleroperationpush) {                return self.animator;    }    return nil;}

uiviewcontrolleranimatedtransitioning

/** * Animation Time Press */-(Nstimeinterval) transitionduration: (ID <UIViewControllerContextTransitioning>) transitioncontext{return 1;}    /** * Performed animation * */-(void) Animatetransition: (id<uiviewcontrollercontexttransitioning>) transitioncontext{ uiviewcontroller* Toviewcontroller = [Transitioncontext viewcontrollerforkey:    Uitransitioncontexttoviewcontrollerkey]; uiviewcontroller* Fromviewcontroller = [Transitioncontext viewcontrollerforkey:    Uitransitioncontextfromviewcontrollerkey];    [[Transitioncontext Containerview] addSubview:toViewController.view];        ToViewController.view.alpha = 0; [UIView animatewithduration:[self Transitionduration:transitioncontext] animations:^{catransition *tion = [C        Atransition Animation];        Tion.type = @ "Oglflip";        Tion.subtype = Kcatransitionfromtop;        Tion.duration = 1;                [FromViewController.view.layer addanimation:tion Forkey:nil]; FromViewController.view.transform = Cgaffinetransformmakerotation (0.5);//cgaffinetransformmakescale (0.1, 0.1);    ToViewController.view.alpha = 1;        } completion:^ (BOOL finished) {fromViewController.view.transform = cgaffinetransformidentity; [Transitioncontext completetransition:!    [Transitioncontext transitionwascancelled]]; }];}

  

Fingerprint unlock and custom transition animations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.