美文网首页
序列帧动画的实现

序列帧动画的实现

作者: 在逃科学家 | 来源:发表于2017-04-26 09:18 被阅读128次
序列帧动画效果图

实现源码:

#import "ViewController.h"@interface ViewController ()@property (weak, nonatomic) IBOutlet UIImageView *imageView;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];}//点击view就会调用此方法-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event{

//创建可变数组加载图片

NSMutableArray *arrM=[NSMutableArray array];

//2.for循环添加凭借图片名称并加载图片

for (NSInteger i=0; i<25; i++) {

//3.拼接图片名称

NSString *imageName=[NSString stringWithFormat:@"father%03zd",i+1];

//4.加载图片

UIImage *image=[UIImage imageNamed:imageName];

//5.把图片添加到可变数组保存起来

[arrM addObject:image];

}

//图片拼接成动态图片

UIImage *animationImage=[UIImage animatedImageWithImages:arrM duration:arrM.count*0.2];

self.imageView.image=animationImage;

}

@end

GitHub源码地:https://github.com/KeithBigBather666/-02.git

相关文章

网友评论

      本文标题:序列帧动画的实现

      本文链接:https://www.haomeiwen.com/subject/rsubzttx.html