您的位置:首页 > 产品设计 > UI/UE

IOS开发------图片浏览器之UIImageView中的animation

2014-10-13 23:18 302 查看
本节主要讲解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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息