Tom Cat Code implementation

Source: Internet
Author: User

////VIEWCONTROLLER.M//Tom////Created by Administrator on 15/8/4.//Copyright (c) 2015 Gengcong. All rights reserved.// #import "ViewController.h" @interfaceViewcontroller () @property (weak, nonatomic) Iboutlet Uiimageview*Tom;-(Ibaction) Drinkclick: (ID) sender;-(Ibaction) Peiclick: (ID) sender;-(Ibaction) Eatclick: (ID) sender;-(Ibaction) Cymbalclick: (ID) sender;-(Ibaction) Scratchclick: (ID) sender;-(Ibaction) Fart: (ID) sender;-(ibaction) Stomach: (ID) sender;-(Ibaction) Footleft: (ID) sender;-(Ibaction) Footright: (ID) sender;-(Ibaction) Knockoutclick: (ID) sender;-(Ibaction) Angryclick: (ID) sender; @end @implementationViewcontroller-(Ibaction) Drinkclick: (IDsender {[Self runanimationwithname:@"Drink"Andcount:Bayi];} -(Ibaction) Peiclick: (IDsender {[Self runanimationwithname:@"Pie"Andcount: -];} -(Ibaction) Eatclick: (IDsender {[Self runanimationwithname:@"Eat"Andcount: +];} -(Ibaction) Cymbalclick: (IDsender {[Self runanimationwithname:@"Cymbal"Andcount: -];} -(Ibaction) Scratchclick: (IDsender {[Self runanimationwithname:@"Scratch"Andcount: About];} -(Ibaction) Fart: (IDsender {[Self runanimationwithname:@"fart"Andcount: -];} -(ibaction) Stomach: (IDsender {[Self runanimationwithname:@"Stomach"Andcount: the];} -(Ibaction) Footleft: (IDsender {[Self runanimationwithname:@"Footright"Andcount: -];} -(Ibaction) Footright: (IDsender {[Self runanimationwithname:@"Footleft"Andcount: -];} -(Ibaction) Knockoutclick: (IDsender {[Self runanimationwithname:@"Knockout"Andcount:Bayi];} -(Ibaction) Angryclick: (IDsender {[Self runanimationwithname:@"Angry"Andcount: -];} -(void) Runanimationwithname: (nsstring*) name Andcount: (int) counts{if(self.tom.isAnimating)return; Nsmutablearray*images=[[Nsmutablearray alloc]init];  for(intI=0; i<counts; i++) {NSString*thanten=[[NSString Alloc]init]; if(i<Ten) {Thanten=[nsstring stringWithFormat:@"0%d", I]; }        Else{Thanten=[nsstring stringWithFormat:@"%d", I]; } nsstring*filename=[nsstring stringWithFormat:@"%@_%@.jpg", Name,thanten]; UIImage*image=[UIImage Imagenamed:filename];    [Images Addobject:image]; }    //Animate a picture sourceself.tom.animationImages=images; //set the number of playsSelf.tom.animationRepeatCount=1; //set the time the animation playsself.tom.animationDuration=images.count*0.07;    [Self.tom startanimating]; //set delay to clear memorycgfloat Delay=self.tom.animationduration +1.0;    [Self.tom performselector: @selector (setanimationimages:) Withobject:nil Afterdelay:delay]; }//-(void) clean//{//Self.tom.animationimages=nil;//    //[Self.tom Setanimationimages:nil];//    //}  @end 

Tom Cat Code implementation

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.