Pull, drop-down uitableview, interactive modal popup (custom popup animation)

Source: Internet
Author: User

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)

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.