IOS Core Animation Cores Animation

Source: Internet
Author: User

Related information:

This theory is much more: http://www.360doc.com/content/15/0727/09/20918780_487655250.shtml

This practice is more, the common effect has http://www.cnblogs.com/wengzilin/p/4250957.html

Example: magnification effect. The idea is to let Calayer move, Cabasicanimation is how to move, and then add the animation to Calayer

    //actor InitializationCalayer *scalelayer =[[Calayer alloc] init]; Scalelayer.backgroundcolor=[Uicolor Bluecolor].    Cgcolor; Scalelayer.frame= CGRectMake ( -, -, -, -); Scalelayer.cornerradius=Ten;         [Self.view.layer Addsublayer:scalelayer]; //set the script .Cabasicanimation *scaleanimation = [cabasicanimation animationwithkeypath:@"Transform.scale"]; Scaleanimation.fromvalue= [NSNumber numberwithfloat:1.0]; Scaleanimation.tovalue= [NSNumber numberwithfloat:1.5]; Scaleanimation.autoreverses=YES; Scaleanimation.fillmode=kcafillmodeforwards; Scaleanimation.repeatcount=maxfloat; Scaleanimation.duration=0.8; //The curtain[Scalelayer addanimation:scaleanimation Forkey:@"scaleanimation"];

Think: Create a new calayer here, but if I want to get a uiview on the interface (maybe a button, a picture, etc.).

In fact, all views inherit UIView, and each UIView has calayer properties (see the first reference for a description)

So, we can add animations directly to the layer of the view. This makes the code easier to understand.

Here's an example of a view rotation, isn't it?

UIView *v = [[UIView alloc]initwithframe:cgrectmake ( $, -, -, -)]; V.backgroundcolor=[Uicolor Redcolor];    [Self.view Addsubview:v]; Cabasicanimation*an2 = [Cabasicanimation animationwithkeypath:@"transform.rotation"]; An2.fromvalue=0; An2.tovalue= [NSNumber numberwithfloat:m_pi*2]; An2.repeatcount=maxfloat; An2.duration=0.8; [V.layer addanimation:an2 Forkey:@"Caan"];

IOS Core Animation Cores 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.