UIimageView GIF动画

1.代码如下 (注释都有)

 

- (void)viewDidLoad {

    [super viewDidLoad];

    

    UIImageView * bigImageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];

//    创建储存图片的数组

    NSMutableArray * imageArray = [NSMutableArray array];

    for (int i=1; i<19; i++)

    {

//        拼接字符串图片名

        NSString * imageString = [NSString stringWithFormat:@"zixun_%d",i];

//        根据图片获取图片名

        UIImage * image = [UIImage imageNamed:imageString];

//        添加图片到数组

        [imageArray addObject:image];

    }

//    gif图片组

    bigImageView.animationImages = imageArray;

//    播放的速率

    bigImageView.animationDuration = 3;

//    播放次数

    bigImageView.animationRepeatCount = 1;

//    开始动画

    [bigImageView startAnimating];

//添加子视图到view

    [self.view addSubview:bigImageView];

    

    

}

 

posted @ 2016-05-31 10:49  i上小青年  阅读(847)  评论(0编辑  收藏  举报