IOS--序列帧动画属性及相关用法

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

@property (weak, nonatomic) IBOutlet UIImageView *zhaoyunImage;

@end
--------------------------------------------------------------------------------------
#import "ViewController.h"
@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
    
    [self setDonghua:11 andButton:_zhaoyunImage];
}

- (void)setDonghua:(NSInteger)count andButton:(UIImageView *)imageView
{
    NSMutableArray *imagesList = [NSMutableArray array];
    
    for (NSInteger i = 1; i < count; i++) {
        // 生成图像文件名
        NSString *fileName = [NSString stringWithFormat:@"%d.png", i];
        UIImage *image = [UIImage imageNamed:fileName];
        
        // 把图像添加到数组
        [imagesList addObject:image];
    }
    
    [imageView setAnimationImages:imagesList];
    // 2.2 设置动画播放的时长
    [imageView setAnimationDuration:1.0];
    
    // 2.4 设置动画播放次数
    [imageView setAnimationRepeatCount:1];
    
    // 2.3 开始动画
    [imageView startAnimating];
 
}
 
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
@end

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。