Part of the Code Interactivetransition class inherits NSObject:
-(Instancetype) Initwithpresentingcontroller: (Uitableviewcontroller *) PRESENTINGVC Presentedcontroller: ( Uiviewcontroller *) PRESENTEDVC { self=[Super Init]; if(self) {SELF.VC=PRESENTEDVC; Self.vc.transitioningDelegate=Self ; SELF.PRESENTINGVC=PRESENTINGVC; } returnSelf ;}- (void) New_scrollviewwillbegindragging: (Uiscrollview *) ScrollView {self.interactivetransition=[[Uipercentdriveninteractivetransition alloc]init]; [SELF.PRESENTINGVC presentViewController:self.vc Animated:yes completion:nil];}- (void) New_scrollviewdidscroll: (Uiscrollview *) ScrollView {cgfloat OffsetY=fabs (SCROLLVIEW.CONTENTOFFSET.Y); CGFloat screenh= [UIScreen mainscreen].bounds.size.height/3.0; Progress= OffsetY/screenh; Progress= progress-0.3; if(Progress >0) {[Self.interactivetransition updateinteractivetransition:progress]; } }- (void) new_scrollviewwillenddragging {if(Progress <0.4) {[Self.interactivetransition cancelinteractivetransition]; }Else{[Self.interactivetransition finishinteractivetransition]; } self.interactivetransition=Nil;}-(NullableID<UIViewControllerAnimatedTransitioning>) Animationcontrollerforpresentedcontroller: (Uiviewcontroller *) Presented Presentingcontroller: (Uiviewcontroller *) presenting Sourcecontroller: (Uiviewcontroller *) Source {returnself.animation;}- (ID<UIViewControllerInteractiveTransitioning>) Interactioncontrollerforpresentation: (ID<UIViewControllerAnimatedTransitioning>) Animator {returnself.interactivetransition;}
Presentanimation class inheritance NSObject implement Uiviewcontrolleranimatedtransitioning protocol
-(Nstimeinterval) Transitionduration: (ID<UIViewControllerContextTransitioning>) Transitioncontext {return 1.0;}- (void) Animatetransition: (ID<UIViewControllerContextTransitioning>) Transitioncontext {UIView*toview =[Transitioncontext Viewforkey:uitransitioncontexttoviewkey]; UIView*containerview =[Transitioncontext Containerview]; [Containerview Addsubview:toview]; Toview.frame= CGRectMake ( -, ContainerView.bounds.size.height, ContainerView.bounds.size.width- -, ContainerView.bounds.size.height- -); [UIView animatewithduration:[self Transitionduration:transitioncontext] Animations:^{toview.frame=Containerview.bounds; }completion:^(BOOL finished) {[Transitioncontext completetransition:![Transitioncontext transitionwascancelled]]; }]; }
Controller:
-(Interactivetransition *) Interactive {if(!_interactive) {_interactive=[[Interactivetransition alloc]initwithpresentingcontroller:self Presentedcontroller:[[twoviewcontroller Alloc ]init]]; } return_interactive;}- (void) Scrollviewwillbegindragging: (Uiscrollview *) ScrollView {[self.interactive new_scrollviewwillbegindragging:scrollview];}- (void) Scrollviewwillenddragging: (Uiscrollview *) ScrollView withvelocity: (cgpoint) Velocity targetcontentoffset: (inout Cgpoint *) Targetcontentoffset {[self.interactive new_scrollviewwillenddragging];}- (void) Scrollviewdidscroll: (Uiscrollview *) ScrollView {[self.interactive new_scrollviewdidscroll:scrollview];}
Complete code: HTTP://PAN.BAIDU.COM/S/1I3UEWIP
Pull, drop-down uitableview, interactive modal popup (custom popup animation)