IOS animation effects-implement pushviewcontroller default animation Effects

Source: Internet
Author: User

During development, view switching is often encountered. Sometimes we do not switch based on the navigation controller. However, in actual development, sometimes we need to implement the push effect, the following code example shows how to implement the default animation effects of push and POP:

 

1. push default animation effect

 

Catransition * transition = [catransition animation];

Transition. Duration = 0.3f;

Transition. timingfunction = [camediatimingfunction functionwithname: kcamediatimingfunctioneaseineaseout];

Transition. type = kcatransitionpush;

Transition. Subtype = kcatransitionfromright;

Transition. Delegate = self;

[Self. contentview. layer addanimation: Transition forkey: Nil];

 

[Self. contentview addsubview: Self. productdetailcontroller. View];

Note: Self. contentview is the uiview in the project, and self. productdetailcontroller is the controller in the project.

You only need to replace the two with the appropriate content.

 

Ii. Default pop animation effect

 

Catransition * transition = [catransition animation];

Transition. Duration = 0.3f;

Transition. timingfunction = [camediatimingfunction functionwithname: kcamediatimingfunctioneaseineaseout];

Transition. type = kcatransitionpush;

Transition. Subtype = kcatransitionfromleft;

Transition. Delegate = self;

[Self. View. superview. layer addanimation: Transition forkey: Nil];

 

[Self. View removefromsuperview];

 

 

Note: The main page switching display mode is set for. type.

. Subtype sets the page rotation between left and right

Related Article

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.