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];//停止動畫
}

 

效果如下:

 

僅做記錄!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM