//
// ViewController.m
// UI02_UIImageView
//
// Created by lanou3g on 17/8/4.
// Copyright © 2017年 lanou3g. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"2.png"]];
// imageView.frame = CGRectMake(100, 100, 100, 100);
// [self.view addSubview:imageView];
NSMutableArray *imageArray = [NSMutableArray array];
for (int i = 0; i <= 21; i++) {
NSString *imageName = [NSString stringWithFormat:@"Zombie%d.tiff",i];
UIImage *image = [UIImage imageNamed:imageName];
[imageArray addObject:image];
}
UIImageView *zombieImageView = [[UIImageView alloc] initWithImage:[imageArray firstObject]];
zombieImageView.frame = CGRectMake(200, 200, 200, 200);
[self.view addSubview:zombieImageView];
//设置播放一组图片
zombieImageView.animationImages = imageArray;
//设置播放一组图片的总时长
zombieImageView.animationDuration = 0.2;
//设置播放一组图片循环次数(0为无限循环)
zombieImageView.animationRepeatCount = 0;
//开始播放
[zombieImageView startAnimating];
//平移动画
[UIView animateWithDuration:5.f animations:^{
zombieImageView.frame = CGRectMake(-200, 100, 200, 200);
}completion:^(BOOL finished) {
[UIView animateWithDuration:5.f animations:^{
zombieImageView.frame = CGRectMake(200, 200, 200, 200);
}];
}];
}
//封装动画方法
- (void)animation:(UIView *)animationView duration:(NSTimeInterval)duration frame:(CGRect)frame {
[UIView animateWithDuration:duration animations:^{
animationView.frame = frame;
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
UIImageView(07-08-05)
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 小学语文修改病句的方法 修改病句是小学语文考试中常见的题型,在修改病句之前,我们应该清晰的了解有哪些病句现象,下面...