汤姆猫实现代码
2015-08-20 18:59
337 查看
// // ViewController.m // Tom // // Created by administrator on 15/8/4. // Copyright (c) 2015年 gengcong. All rights reserved. // #import "ViewController.h" @interface ViewController () @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 @implementation ViewController - (IBAction)drinkClick:(id)sender { [self runAnimationWithName:@"drink" andcount:81]; } - (IBAction)peiClick:(id)sender { [self runAnimationWithName:@"pie" andcount:24]; } - (IBAction)eatClick:(id)sender { [self runAnimationWithName:@"eat" andcount:40]; } - (IBAction)cymbalClick:(id)sender { [self runAnimationWithName:@"cymbal" andcount:13]; } - (IBAction)scratchClick:(id)sender { [self runAnimationWithName:@"scratch" andcount:56]; } - (IBAction)fart:(id)sender { [self runAnimationWithName:@"fart" andcount:28]; } - (IBAction)stomach:(id)sender { [self runAnimationWithName:@"stomach" andcount:34]; } - (IBAction)footleft:(id)sender { [self runAnimationWithName:@"footRight" andcount:30]; } - (IBAction)footright:(id)sender { [self runAnimationWithName:@"footLeft" andcount:30]; } - (IBAction)knockoutClick:(id)sender { [self runAnimationWithName:@"knockout" andcount:81]; } - (IBAction)angryClick:(id)sender { [self runAnimationWithName:@"angry" andcount:26]; } -(void)runAnimationWithName:(NSString*)name andcount:(int)counts { if (self.tom.isAnimating) return; NSMutableArray *images=[[NSMutableArray alloc]init]; for (int i=0; i<counts; i++) { NSString *thanten=[[NSString alloc]init]; if (i<10){ 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]; } // 设置动画的图片来源 self.tom.animationImages=images; // 设置播放次数 self.tom.animationRepeatCount=1; //设置动画播放的时间 self.tom.animationDuration=images.count*0.07; [self.tom startAnimating]; //设置延时清除内存 CGFloat 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
相关文章推荐
- 【Java】-基础-数据库操作
- PHP模板引擎的原理与实践
- 不要以多态的方式处理数组(More Effective-C++_3(基础))
- Qt:Invalid parameter passed to C runtime function.
- Java代码常用工具--Draft
- Spring学习笔记——Spring事务只对运行时异常回滚
- 02-C#(基础)基本的定义和说明
- vs2010 release 模式加了断点,跑代码无法跟踪,解决方法
- Quartz(二)整合Spring容器中bean及动态调度任务
- 1小时内必须解决的5个编程问题
- Java变量及其传递
- HDU 4341 Gold miner (分组背包)
- Java 螺纹第三版 第三章数据同步 读书笔记
- 在spring中使用quartz进行任务调度遇到的问题
- thinkphp3.2.3 ueditor1.4.3 图片上传操作,在线删除上传图片功能。
- thinkphp3.2.3 ueditor1.4.3 图片上传操作,在线删除上传图片功能。
- hdu1069//zoj1093 Monkey and Banana (排序,dp)
- Event C++初识
- Python循环语句
- C# 对象锁——Monitor