#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *catImageView;
- (IBAction)doCymbal:(UIButton *)sender;
- (IBAction)doDrink:(UIButton *)sender;
- (IBAction)doEat:(UIButton *)sender;
- (IBAction)doFart:(UIButton *)sender;
- (IBAction)doPie:(UIButton *)sender;
- (IBAction)doScratch:(UIButton *)sender;
@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)beginAnimationWithCount:(int)count andName:(NSString*)name {
if (_catImageView.isAnimating) {
[_catImageView stopAnimating];
}
//接收图片
NSMutableArray* image_array = [NSMutableArray array];
for (int i=0; i<=count; i++) {
NSString* imageName = [NSString stringWithFormat:@"%@_d.jpg",name,i];
//有缓存
//UIImage *image = [UIImage imageNamed:imageName];
//没有缓存
NSString*path=[[NSBundle mainBundle]pathForResource:imageName ofType:nil];
UIImage*image=[UIImage imageWithContentsOfFile:path];
[image_array addObject:image];
}
_catImageView.animationImages = image_array;//展示动画
_catImageView.animationDuration = [image_array count]*0.1;
_catImageView.animationRepeatCount = 1;
[_catImageView startAnimating];
//一次动画后释放内存
[_catImageView performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:[image_array count]*0.1];
}
- (IBAction)doCymbal:(UIButton *)sender {
[self beginAnimationWithCount:12 andName:@"cymbal"];
}
- (IBAction)doDrink:(UIButton *)sender{
[self beginAnimationWithCount:80 andName:@"drink"];
}
- (IBAction)doEat:(UIButton *)sender{
[self beginAnimationWithCount:39 andName:@"eat"];
}
- (IBAction)doFart:(UIButton *)sender{
[self beginAnimationWithCount:27 andName:@"fart"];
}
- (IBAction)doPie:(UIButton *)sender{
[self beginAnimationWithCount:23 andName:@"pie"];
}
- (IBAction)doScratch:(UIButton *)sender{
[self beginAnimationWithCount:55 andName:@"scratch"];
}
@end
FEATURED TAGS
iOS
OC
C
Xcode
MIMEType
屏幕旋转
Mac
工具
SQLite3
重命名
证书+内购
像素
pch
支付协议税务
APP转让
审核
银行卡格式化
git
描述文件
命令行
沙盒日志
i386
x86_64
控制台log
xcode10&iOS12
正则
textfield
输入限制
Pod
真机支持
封面尺寸
SDWebImage
Ruby
RVM
渐变色
jekyll
水印
富文本
标签
M3U8
动、静态库
异步上传
Url编码解码
AlertController
保活
pod报错
特定UI横竖屏
Launch版本号
ijkplayer
适配
手势
截图
网络和信号
礼物缓存
手绘礼物
UIPickerView
文件权限
键盘和菜单
耗时卡顿
国际化
Paypal
AWSS3
npm、Node
控制台
warning
扩展
防盗链
动画
分析
CallKit
侧滑
重置根控制器
播放器
裁剪
日志
bugly
uniapp
Swift
文字翻转
跨域
WebClip
网络请求
地图导航
ZSH
SPM
Vapor
导航
验证码
杀进程
Ubuntu
Android
JWT
vue
html-js
style-class
ssh
PHP
jks
css
Runtime
tree
uniCloud
圆角
总结