////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