One way to browse large graphs

Source: Internet
Author: User

Using transition animations (which do not say transition animations), is mainly the conversion of several coordinates: the ImageView snapshot on the cell is generated by a snapview (just like creating a imageview), on the cell image on the frame The coordinates are converted to Containerview, and the Snapview is zoomed to the target size (first you need to know what the transition animation is all about).

The following is the main code, and a custom class inherits from NSObject. Implements the Uinavigationcontrollerdelegate, uiviewcontrolleranimatedtransitioning protocol

- (void) Animatetransition: (ID<UIViewControllerContextTransitioning>) Transitioncontext {//gets the current controllerUiviewcontroller *FROMVC =[Transitioncontext Viewcontrollerforkey:uitransitioncontextfromviewcontrollerkey]; //get the controller that will be turnedUiviewcontroller *TOVC =[Transitioncontext Viewcontrollerforkey:uitransitioncontexttoviewcontrollerkey]; //Get container ViewUIView *containerview =[Transitioncontext Containerview]; Uicollectionview*CollectionView; Uiimageview*Contentimageview; if(Self.opration = =Pushanimationoprationpush) {Viewcontroller*from = (Viewcontroller *) Fromvc; CollectionView=From.collectionview; Contentimageview= [ToVC Valueforkey:@"_contentimageview"]; }Else{Viewcontroller*to = (Viewcontroller *) ToVC; CollectionView=To.collectionview; Contentimageview= [Fromvc Valueforkey:@"_contentimageview"]; }        //gets the Indexpath of the selected cellNsarray *selecteditems =[CollectionView Indexpathsforselecteditems]; //get cell according to IndexpathCuscollectionviewcell *cell = (Cuscollectionviewcell *) [CollectionView cellforitematindexpath:[selecteditems firstobject]; UIView*SnapView;    CGRect Snapviewframe;        CGRect Snapviewtargetframe; if(Self.opration = =Pushanimationoprationpush) {                //intercept a snapshot of contentimage on the cellSnapView =[Cell.contentimage Snapshotviewafterscreenupdates:no]; //convert to Containerview based on Contentimage's coordinates on the cellSnapviewframe =[Containerview convertRect:cell.contentImage.frame FromView:cell.contentImage.superview]; //gets the ImageView to be displayed on the target controller and, based on the size position of the imageView, transitions to the container view, becoming the final dimension of Snapview. Snapviewtargetframe =[Containerview convertRect:contentImageView.frame FromView:contentImageView.superview]; }Else{SnapView=[Contentimageview Snapshotviewafterscreenupdates:no]; Snapviewframe=[Containerview convertRect:contentImageView.frame FromView:contentImageView.superview]; Snapviewtargetframe=[Containerview convertRect:cell.contentImage.frame fromView:cell.contentImage]; } snapview.frame=Snapviewframe; ToVC.view.alpha=0;    [Containerview AddSubview:toVC.view];        [Containerview Addsubview:snapview]; Contentimageview.hidden=YES; Cell.contentImage.hidden=YES; [UIView animatewithduration:[self Transitionduration:transitioncontext] Delay:0Usingspringwithdamping:0.6fInitialspringvelocity:1.0fOptions:uiviewanimationoptioncurveeaseinout animations:^{snapview.frame=Snapviewtargetframe; ToVC.view.alpha=1.0; } Completion:^(BOOL finished) {Contentimageview.hidden=NO; Cell.contentImage.hidden=NO;        [SnapView Removefromsuperview]; [Transitioncontext completetransition:![Transitioncontext transitionwascancelled]];    }]; }
- (ID<UIViewControllerAnimatedTransitioning>) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller animationcontrollerforoperation: (uinavigationcontrolleroperation) operation Fromviewcontroller: (Uiviewcontroller *) Fromvc Toviewcontroller: (Uiviewcontroller *) ToVC {if(Operation = =Uinavigationcontrolleroperationpush) {self.opration=Pushanimationoprationpush; }Else if(Operation = =Uinavigationcontrolleroperationpop) {self.opration=Pushanimationoprationpop; }    returnSelf ;}- (void) Start {Self.nav.Delegate=Self ;}/** Add a tap gesture to the target controller to return to the previous controller*/- (void) Tapgesturetopopwithcontroller: (Uiviewcontroller *) TARGETVC {Self.targetviewcontroller=TARGETVC; UITapGestureRecognizer*tapgesture =[[UITapGestureRecognizer alloc]initwithtarget:self Action: @selector (tapgesture:)]; [Targetvc.view addgesturerecognizer:tapgesture];}- (void) Tapgesture: (UITapGestureRecognizer *) gesture {[Self.targetViewController.navigationController popviewcontrolleranimated:yes];}

One way to browse large graphs

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.