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