
序列幀動(dòng)畫效果圖
實(shí)現(xiàn)源碼:
#import "ViewController.h"@interface ViewController ()@property (weak, nonatomic) IBOutlet UIImageView *imageView;@end@implementation ViewController- (void)viewDidLoad {? ? [super viewDidLoad];}//點(diǎn)擊view就會(huì)調(diào)用此方法-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event{
//創(chuàng)建可變數(shù)組加載圖片
NSMutableArray *arrM=[NSMutableArray array];
//2.for循環(huán)添加憑借圖片名稱并加載圖片
for (NSInteger i=0; i<25; i++) {
//3.拼接圖片名稱
NSString *imageName=[NSString stringWithFormat:@"father%03zd",i+1];
//4.加載圖片
UIImage *image=[UIImage imageNamed:imageName];
//5.把圖片添加到可變數(shù)組保存起來
[arrM addObject:image];
}
//圖片拼接成動(dòng)態(tài)圖片
UIImage *animationImage=[UIImage animatedImageWithImages:arrM duration:arrM.count*0.2];
self.imageView.image=animationImage;
}
@end