iOS custom segue and custom segue transitions animations

Source: Internet
Author: User

Custom Segue need to inherit the Uistoryboardsegue class, and then override the -(void) perform; method. You can customize the transition animation in the method.


</pre><span style= "Color:rgb (97, 34, 174); Font-family:courier; font-size:18px; " >coolsegue.h file </span><p></p><p></p><pre code_snippet_id= "420043" snippet_ File_name= "blog_20140707_2_5708153" name= "code" class= "OBJC" > #import <UIKit/UIKit.h> @interface coolsegue: Uistoryboardsegue@end


COOLSEGUE.M file

#import "CoolSegue.h" @implementation coolsegue-(void) perform{uiviewcontroller* Source = Self.sourceviewcontroller;    uiviewcontroller* destination = Self.destinationviewcontroller;    Uigraphicsbeginimagecontext (destination.view.bounds.size);    Cgcontextref contextref = Uigraphicsgetcurrentcontext ();    [Destination.view.layer Renderincontext:contextref];    uiimage* desimage = Uigraphicsgetimagefromcurrentimagecontext ();    Uigraphicsendimagecontext ();    uiimageview* IView = [[Uiimageview alloc] initwithimage:desimage];    [IView Setbackgroundcolor:[uicolor Graycolor]; Iview.autoresizingmask = uiviewautoresizingflexiblewidth|    Uiviewautoresizingflexibleheight;    Iview.contentmode = Uiviewcontentmodecenter;    [Source.parentViewController.view Addsubview:iview];    Cgaffinetransform Scalet = Cgaffinetransformmakescale (0.1, 0.1);    Cgaffinetransform rotatet = cgaffinetransformmakerotation (M_PI);    Iview.transform = Cgaffinetransformconcat (Scalet, rotatet); Iview.transfoRM =cgaffinetransformtranslate (Cgaffinetransformconcat (Scalet, Rotatet), 1, 1);    Cgpoint originpoint = Iview.center;    Iview.center = Cgpointmake (IView.bounds.size.width, iView.bounds.size.height);    Iview.center = Cgpointmake (Originpoint.x-iview.bounds.size.width, ORIGINPOINT.Y); [UIView animatekeyframeswithduration:0.8 delay:0 Options:uiviewkeyframeanimationoptioncalculationmodecubic        animations:^{iview.transform = cgaffinetransformidentity;    Iview.center = Originpoint; }completion:^ (BOOL finished) {[Self.sourceviewcontroller PresentViewController:self.destinationViewController Anim         Ated:yes Completion:nil];    [IView Removefromsuperview]; }];}


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.