iOS ImageView加载多图动画

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
- (void)startAnimationView{
//创建UIImageView,添加到界面
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"fzg_anim_splash_1"]];
CGSize imageSize = CGSizeMake(image.size.width, image.size.height);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 0, self.view.bounds.size.width - 60, ((self.view.bounds.size.width - 60)*imageSize.height)/imageSize.width)];
imageView.center = self.view.center;
imageView.contentMode = UIViewContentModeScaleAspectFit;
[self.view addSubview:imageView];

//创建一个数组,数组中按顺序添加要播放的图片(图片为静态的图片)
NSMutableArray *imageArr = [NSMutableArray array];
for (int i = 1; i < 32; i++) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"fzg_anim_splash_%d", i]];
[imageArr addObject:image];
}
//把存有UIImage的数组赋给动画图片数组
imageView.animationImages = imageArr;
//设置执行一次完整动画的时长
imageView.animationDuration = 3.5;
//动画重复次数 (0为重复播放)
imageView.animationRepeatCount = 1;
//开始播放动画
[imageView startAnimating];
//自动移除动画图层,延迟4秒执行
[self performSelector:@selector(removeAnimationView) withObject:nil afterDelay:4.f];
}

- (void)removeAnimationView{
NSLog(@"移除动画");
[self.view removeFromSuperview];
}
-------------本文结束感谢您的阅读-------------
最近的文章

iOS 报错Attempt to present...whose view is not in the window hierarchy!

Attempt to present &lt;*ViewController: 0x**&gt; on &lt;ViewController: 0x**&gt; whose view is not in the window hierarchy!123456789101112131415161718 …

继续阅读
更早的文章

算法

1. 不用中间变量,用两种方法交换A和B的值1234567891011121314151617181920&#x2F;&#x2F; 1.中间变量void swap(int a, int b) &#123; int temp &#x3D; a; a &#x3D; b; b &#x3D …

继续阅读