Animate images in uiimageview

To download images from web service:

NSData *imageData = [NSData dataWithContentsOfURL:"*Url from web service*"];
UIImage *imageOne = [UIImage imageWithData:imageData];

likely download all images from web service and create an array like:

NSArray *imagesArray = [NSArray arrayWithObjects:imageOne...........,nil];

and use with little modification:

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = imagesArray;
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[self.view addSubview: animatedImageView];

Got a Perfect code for animation can automatically change images in image view in swift4

class ViewController: UIViewController {

var imgarray = [UIImage(named:"f1.png")!, 
                UIImage(named:"f2.png")!, 
                UIImage(named:"f3.png")!,  
                UIImage(named:"f4.png")!,
                UIImage(named:"f5.png")!, 
                UIImage(named:"index1.png")!,
                UIImage(named:"index2.png")!, 
                UIImage(named:"index3.png")!]

@IBOutlet weak var imgview: UIImageView!
override func viewDidLoad() {
    super.viewDidLoad()

    self.imgview.animationImages = imgarray
    self.imgview.animationDuration = 10.0
    self.imgview.animationRepeatCount = 0
    self.imgview.startAnimating()
    }
}

Swift

Assuming that imageView is added via storyboard

Intialize array:

self.imageArray = [UIImage(named:"Download_060.png")!,UIImage(named:"Download_061.png")!,UIImage(named:"Download_062.png")!,
                       UIImage(named:"Download_063.png")!,UIImage(named:"Download_064.png")!,UIImage(named:"Download_065.png")!,
                       UIImage(named:"Download_066.png")!,UIImage(named:"Download_067.png")!]

Add Code to animate on button action or as per required

 self.imgView.animationImages = self.imageArray
        self.imgView.animationDuration = 1.0
        self.imgView.animationRepeatCount = 0
        self.imgView.startAnimating()

Stop Animation

self.imgView.animationRepeatCount = 1 // IF Require once set this 1, 0 == infinite 

OR

self.imgView.stopAnimating()