圖片動畫實現,代碼如下:
-(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];//停止動畫 }
效果如下:
僅做記錄!