iOS开发之--UIImageView的animationImages动画

图片动画实现,代码如下:

-(UIImageView *)animationImageView
{
    if (!_animationImageView) {
        _animationImageView= [[UIImageView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2-180/2, self.view.frame.size.height/2-180/2, 180, 180)];
        [self.view addSubview:_animationImageView];
    }
    return _animationImageView;
}

-(void)buildAnimationImageView
{
    NSArray *ary = @[[UIImage imageNamed:@"image1"],
                     [UIImage imageNamed:@"image2"],
                     [UIImage imageNamed:@"image3"],
                     [UIImage imageNamed:@"image4"]
                     ];
    self.animationImageView.animationImages = ary;
    self.animationImageView.animationDuration = 5;//动画时间
    self.animationImageView.animationRepeatCount = 0;//动画重复次数,0:无限
    [self.animationImageView startAnimating];//开始动画
//    [self.animationImageView stopAnimating];//停止动画
}

 

效果如下:

 

仅做记录!

posted @ 2019-01-28 13:23  稻草人11223  阅读(2100)  评论(0编辑  收藏  举报
返回顶部