1.//按鈕函數(shù)
- (IBAction)beginAction:(UIButton*)sender {
NSLog(@"我做動作了");
switch(sender.tag) {
case100:{
//執(zhí)行核心功能模塊
[selfanimationImageNmae:@"cymbal"WithAccount:13];
}break;
case101:{
[selfanimationImageNmae:@"fart"WithAccount:28];
}break;
case102:
[selfanimationImageNmae:@"eat"WithAccount:40];
break;
case103:
[selfanimationImageNmae:@"drink"WithAccount:81];
break;
case104:
[selfanimationImageNmae:@"scratch"WithAccount:56];
break;
case105:
[selfanimationImageNmae:@"pie"WithAccount:24];
break;
case106:
[selfanimationImageNmae:@"stomach"WithAccount:34];
break;
case107:
[selfanimationImageNmae:@"foot_right"WithAccount:30];
break;
case108:
[selfanimationImageNmae:@"foot_left"WithAccount:30];
break;
case109:
[selfanimationImageNmae:@"knockout"WithAccount:81];
break;
case110:
[selfanimationImageNmae:@"angry"WithAccount:26];
break;
default:
break;
}
}
2.//核心功能模塊
-(void)animationImageNmae:(NSString*)name WithAccount:(int)count{
//新建數(shù)組
NSMutableArray*tempArray = [NSMutableArraynew];
//往數(shù)組里加圖片
for(intindex=0;index
//找圖片
NSString*imageName=[NSStringstringWithFormat:@"%@_%02d.jpg",name,index];
UIImage*image=[UIImageimageNamed:imageName];
//把圖片放到數(shù)組
[tempArrayaddObject:image];
}
//把圖片給圖片試圖
self.backImageView.animationImages=tempArray;
//設(shè)置動畫的執(zhí)行次數(shù)
self.backImageView.animationRepeatCount=1;
//動畫的執(zhí)行時間
self.backImageView.animationDuration=0.1*count;
//開始動畫
[self.backImageViewstartAnimating];
}