ios9--UIImageView的帧动画

简介:
复制代码
//
//  ViewController.m
//  05-UIImageView的帧动画
//

#import "ViewController.h"

@interface ViewController ()
/**
 *  属性
 */
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.imageView.image = [UIImage imageNamed:@"q1"];
    
}

#pragma mark - 开始动画
- (IBAction)startAnimation {
    // 1.1 加载所有的图片
    NSMutableArray<UIImage *> *imageArr = [NSMutableArray array];
    for (int i=0; i<20; i++) {
        // 获取图片的名称
        NSString *imageName = [NSString stringWithFormat:@"%d", i+1];
        // 创建UIImage对象
        UIImage *image = [UIImage imageNamed:imageName];
        // 加入数组
        [imageArr addObject:image];
    }
    // 设置动画图片
    self.imageView.animationImages = imageArr;
    
    // 设置动画的播放次数
    self.imageView.animationRepeatCount = 0;
    
    // 设置播放时长
    // 1秒30帧, 一张图片的时间 = 1/30 = 0.03333 20 * 0.0333
    self.imageView.animationDuration = 1.0;
    
    // 开始动画
    [self.imageView startAnimating];
}

#pragma mark - 结束动画
- (IBAction)overAnimation {
    [self.imageView stopAnimating];
}
@end
复制代码

 


本文转自农夫山泉别墅博客园博客,原文链接:http://www.cnblogs.com/yaowen/p/7448288.html,如需转载请自行联系原作者

相关文章
|
API iOS开发 Perl
iOS UIImageView文字头像,首字母缩略头像
iOS UIImageView文字头像,首字母缩略头像
iOS UIImageView文字头像,首字母缩略头像
|
iOS开发
iOS中UIImageView用法总结
iOS中UIImageView用法总结
100 0
|
iOS开发
iOS UIImageView(图片)
UIImageView属性 1.Image 设置图片,默认显示 UIImageView *_imageView = [[UIImageView alloc]init]; _imageView.
1089 0
|
缓存 iOS开发 程序员
|
iOS开发 应用服务中间件
iOS - UIImageView 动画
1、UIImageView 动画 1.1 播放图片集 播放图片集 @property (nonatomic, strong) UIImageView *playImageView; self.
921 0