iOS 18th day (5,cabasicanimation basic animation)

Source: Internet
Author: User

*******

#import "HMViewController.h"@interfaceHmviewcontroller () @property (nonatomic, weak) Calayer*layer;@end@implementationHmviewcontroller- (void) viewdidload{[Super Viewdidload]; //additional setup after loading the view, typically from a nib.Calayer*layer =[Calayer layer]; Layer.position= Cgpointmake ( -, -); Layer.bounds= CGRectMake (0,0, -, -); Layer.backgroundcolor=[Uicolor Redcolor].        Cgcolor; Layer.contents= (ID) [UIImage imagenamed:@"Heart"].        Cgimage;        [Self.view.layer Addsublayer:layer]; _layer=layer; }//animated animation of rotation- (void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event{    //Create an animated objectCabasicanimation *anim =[cabasicanimation animation]; //set the properties of an animationAnim.keypath =@"Transform.scale"; //set the value of the property changeAnim.tovalue = @0.5; //Set Animation durationAnim.duration =0.25; //Cancel Bounce//do not remove animations after the animation has finished executingAnim.removedoncompletion =NO; //keep up-to-date positionAnim.fillmode =kcafillmodeforwards; //number of repetitions of the animationAnim.repeatcount =maxfloat; //Animate a layer[_layer Addanimation:anim forkey:nil];}//Moving Animations- (void) position{//Create an animated objectCabasicanimation *anim =[cabasicanimation animation]; //set the properties of an animationAnim.keypath =@"position"; //set the value of the property changeAnim.tovalue = [Nsvalue valuewithcgpoint:cgpointmake ( $, $)]; //Set Animation durationAnim.duration =2; //Cancel Bounce//do not remove animations after the animation has finished executingAnim.removedoncompletion =NO; //keep up-to-date positionAnim.fillmode =kcafillmodeforwards; //Animate a layer[_layer Addanimation:anim forkey:nil];}@end

iOS 18th day (5,cabasicanimation basic 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.