Core Animation Catransition (transition animation)

Source: Internet
Author: User

Used to animate transitions, which gives the layer an animated effect of moving out of the screen and moving into the screen. iOS has less transition animations than Mac OS X

Uinavigationcontroller is the animation effect of pushing the controller's view into the screen via catransition

Attribute parsing:

Type: Animation transition types

Subtype: Animation transition Direction

Startprogress: Start of Animation (percentage in overall animation)

Endprogress: End of Animation (percentage in overall animation)

Code One:

#import "ViewController.h" @interface Viewcontroller () @property (nonatomic,strong) Uiimageview *imgview;@        End@implementation viewcontroller-(void) viewdidload {[Super viewdidload];    Self.imgview=[[uiimageview Alloc]initwithframe:cgrectmake (100, 200, 200, 200)];    [Self.view AddSubview:self.imgView];    UIButton *btn1=[uibutton Buttonwithtype:uibuttontypecustom];    [Btn1 settitle:@ "on a" forstate:uicontrolstatenormal];    [Btn1 addtarget:self Action: @selector (Btnclick:) forcontrolevents:uicontroleventtouchupinside];    btn1.tag=1;    Btn1.backgroundcolor=[uicolor Redcolor];        Btn1.frame=cgrectmake (50, 100, 80,40);        [Self.view ADDSUBVIEW:BTN1];    UIButton *btn2=[uibutton Buttonwithtype:uibuttontypecustom];    [Btn2 settitle:@ "Next" forstate:uicontrolstatenormal];    btn2.tag=2;    [Btn2 addtarget:self Action: @selector (Btnclick:) forcontrolevents:uicontroleventtouchupinside];    Btn2.frame=cgrectmake (150, 100, 80,40);    Btn2.backgroundcolor=[uicolor Redcolor]; [Self. View ADDSUBVIEW:BTN2];    }-(void) Btnclick: (ID) sender{UIButton *btn= (UIButton *) sender;        if (btn.tag==1) {self.imgview.image=[uiimage imagenamed:@ "1.jpg"];        Catransition *transition=[catransition Animation];        Animation effect [email protected] "push";        Animation direction transition.subtype=kcatransitionfromright;        transition.duration=2.0;    [Self.imgView.layer addanimation:transition Forkey:nil];        } else {self.imgview.image=[uiimage imagenamed:@ "2.jpg"];        Catransition *transition=[catransition Animation];        Transition.type=kcatransitionmovein;        Transition.subtype=kcatransitionfrombottom;        transition.duration=2.0;    [Self.imgView.layer addanimation:transition Forkey:nil];    }}-(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} @end

Code two:

Core Animation Catransition (transition 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.