本节主要讲解UIImageView中的动画操作:
常用的几个方法的名称:
①setAnimationImages:设置动画的图片,参数为数组NSArray
②setAnimationDuration:设置时间间隔,参数为浮点数
③setAnimationRepeatCount:设置重复次数
④startAnimating:动画开始
⑤stopAnimating:结束动画
ViewController.h文件
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIImageView *zhaoyunImage;
@end
ViewController.m文件
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSMutableArray *array = [NSMutableArray array];
for (int i = 1; i <= 10; ++i) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png",i]];
[array addObject:image];
}
[_zhaoyunImage setAnimationImages:array];
[_zhaoyunImage setAnimationDuration:1.0];
[_zhaoyunImage setAnimationRepeatCount:100];
[_zhaoyunImage startAnimating];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end