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];//停止动画
}

效果如下:

仅做记录!

猜你喜欢

转载自www.cnblogs.com/hero11223/p/10329824.html