06-TOM汤姆猫
2016-01-17 19:20
316 查看
// // ViewController.m // 06-TOM汤姆猫 // // Created by yibooo on 16/1/17. // Copyright © 2016年 yibooo. All rights reserved. // #import "ViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIImageView *tom; - (IBAction)drink; - (IBAction)knock; - (IBAction)rithtFoot; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)runAnimationsWithCount:(int)count name:(NSString *)name{ if ([self.tom isAnimating]) { return; } NSMutableArray *imageArray = [NSMutableArray array]; for (int i = 0; i < count; i++) { NSString *fileName = [NSString stringWithFormat:@"%@_%02d.jpg", name, i]; UIImage *image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fileName ofType:nil]]; [imageArray addObject:image]; } self.tom.animationImages = imageArray; self.tom.animationRepeatCount = 1; self.tom.animationDuration = count * 0.05; [self.tom startAnimating]; // 清理内存 [self.tom performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.tom.animationDuration + 1.0]; } - (IBAction)drink { [self runAnimationsWithCount:81 name:@"drink"]; } - (IBAction)knock { [self runAnimationsWithCount:81 name:@"knockout"]; } - (IBAction)rithtFoot { [self runAnimationsWithCount:30 name:@"footRight"]; } @end
相关文章推荐
- swift错误:expected a digit after integer literal prefix
- 题目1254:N皇后问题
- 大数据
- HTML5之FileReader的使用
- iwork8平板电脑安装ubuntu,Z3735d/f系列CPU通用
- Android自动化测试中uiautomator批改uiautomatorviewer获取不到动态界面的缺陷
- .framework以及.a合并相关
- JS forEach函数
- Google Java编程库Guava介绍
- 【codevs1666】买票
- bShare分享-分享到微信、微博、QQ
- flex布局的使用,纪念第一次开发手机网站
- typedef的用法 单向链表的查找、增加、删除、销毁。
- 5、数组
- java String 类的基本方法
- 经典排序算法 - 归并排序Merge sort
- Android中EditText+Button组合,输入板无法收起问题解决方法
- PHPExcel探索之旅---阶段一
- 搁浅一笺思念,静候几度时光。
- 输出 函数调用栈