#import "BEViewController.h"
NSDictionary *_allDict;
@interface BEViewController ()
@end
@implementation BEViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSBundle *bundel = [NSBundle mainBundle];
NSString *path = [bundel pathForResource:@"tom.plist" ofType:nil];
_allDict = [NSDictionary dictionaryWithContentsOfFile:path];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)ShowTom:(int)count setMark:(NSString *)imgMark{
//1、创建可变数组
NSMutableArray *images = [NSMutableArray array];
//2、循环添加图片
for (int i=0;i<count;i++) {
//获取文件名字
NSString *imageName = [NSString stringWithFormat:@"%@_%02d.jpg",imgMark,i];
//跟进文件名字获取绝对路径
NSString *imgpath = [[NSBundle mainBundle] pathForResource:imageName ofType:nil];
//根据文件路径取出文件名
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgpath];
[images addObject:img];
}
//3、按顺序播放图片动画
_tom.animationImages = images;
_tom.animationDuration = count * 0.1;
//4、设置只播放一次
_tom.animationRepeatCount = 1;
[_tom startAnimating];
}
- (IBAction)btnClick:(UIButton *)sender {
//获取button的title值
NSString *tit = [sender titleForState:UIControlStateNormal];
int coumens = [_allDict[tit] intValue];
[self ShowTom:coumens setMark:tit];
}
@end

下一篇:Mac 终端启动 xampp 下的服务器命令