Controller Transitions Animation detailed
Effect
Description
1. The controller transition animation includes the present and dismiss transition animations of the common controller, as well as the navigationcontroller push and pop transitions animations. Among them, Navigationcontroller pop animations contain a fallback percent display
2. Abstract behavior of the Transition animation object, making it easier to use
3. Instant simplification of the use, controller transitions animation is also a difficult to master
Source
Https://github.com/YouXianMing/ViewControllersTransition
////BaseAnimator.h//viewcontrollerstransition////Created by youxianming on 15/7/21.//Copyright (c) 2015 youxianming. All rights reserved.//#import<Foundation/Foundation.h>#import<UIKit/UIKit.h>@interfaceBaseanimator:nsobject <UIViewControllerAnimatedTransitioning>/** * Animation execution time (default value is 0.5s)*/@property (nonatomic) nstimeinterval transitionduration;/** = = Subclasses override this method to implement animation effects = = * Animated Events*/- (void) animatetransitionevent;/** = = used in animatetransitionevent only valid = * * Source Controller*/@property (nonatomic,ReadOnly, weak) Uiviewcontroller *Fromviewcontroller;/** = = used in animatetransitionevent only valid = * * Target controller*/@property (nonatomic,ReadOnly, weak) Uiviewcontroller *Toviewcontroller;/** = = used in animatetransitionevent only valid = * * Containerview*/@property (nonatomic,ReadOnly, weak) UIView *Containerview;/** * Animation event ended*/- (void) completetransition;@end
////BASEANIMATOR.M//viewcontrollerstransition////Created by youxianming on 15/7/21.//Copyright (c) 2015 youxianming. All rights reserved.//#import "BaseAnimator.h"@interfacebaseanimator () @property (nonatomic, weak)ID<UIViewControllerContextTransitioning>Transitioncontext, @property (nonatomic, weak) Uiviewcontroller*Fromviewcontroller, @property (nonatomic, weak) Uiviewcontroller*Toviewcontroller, @property (nonatomic, weak) UIView*Containerview;@end@implementationBaseanimator#pragmaMark-Initialize-(instancetype) init { self=[Super Init]; if(self) {//Default parameter Settings[self deafultset]; } returnSelf ;}- (void) Deafultset {_transitionduration=0.5f;}#pragmaMark-Animation Agent-(Nstimeinterval) Transitionduration: (ID<UIViewControllerContextTransitioning>) Transitioncontext {return_transitionduration;}- (void) Animatetransition: (ID<UIViewControllerContextTransitioning>) Transitioncontext {Self.fromviewcontroller=[Transitioncontext Viewcontrollerforkey:uitransitioncontextfromviewcontrollerkey]; Self.toviewcontroller=[Transitioncontext Viewcontrollerforkey:uitransitioncontexttoviewcontrollerkey]; Self.containerview=[Transitioncontext Containerview]; Self.transitioncontext=Transitioncontext; [Self animatetransitionevent];}- (void) animatetransitionevent {/*= = code example = = UIView *tmpview = [[UIView alloc] Initwithframe:cgrectmake (0, 0, 100, 100)]; [Self.containerview AddSubview:self.toViewController.view]; [Self.containerview Addsubview:tmpview]; [UIView animateWithDuration:self.transitionDuration delay:0.0f usingspringwithdamping:1 I NITIALSPRINGVELOCITY:0.F options:0 animations:^{tmpview.frame = CGRectMake (0, 0, 100, 100); } completion:^ (BOOL finished) {[Tmpview Removefromsuperview]; [Self completetransition]; }]; */}#pragmaMark--(void) completetransition {[Self.transitioncontext completetransition:!self.transitionContext.transitionWasCancelled];}@end
Details
What you need to do with the navigation bar Controller animation (* To add a fallback percentage, not required)
1. Add an agreement
2. Add an Agent
3. Implementing the Protocol Approach
* 4. Add uipercentdriveninteractivetransition Object
* 5. Adding Edge gestures
* 6. Achieve percent agreement
* 7. Implementing Gesture methods
Things to do with normal controller animations
1. Add an agreement
2. Easy configuration of the controller
3. Implementing the Proxy Protocol
Controller Transitions Animation detailed