I am working on the UIImageView transition in swift. I an storing six images in an array and giving that array to “imageview.animationImages ” and I am trying to making it to work as ‘Gif animation’ the code I wrote is as follows :
logoImages = NSMutableArray(array: ["backGround4.jpeg","backGround3.jpeg","backGround.jpeg","16.jpeg","23.jpeg","backGround1.jpeg"])
imageview.animationImages = NSArray(array: ["backGround4.jpeg","backGround3.jpeg","backGround.jpeg","16.jpeg","23.jpeg","backGround1.jpeg"]) as? [UIImage]
imageview.animationDuration = 1.5
imageview.animationRepeatCount = 1
imageview.startAnimating()
It is not working.Can anyone please tell me what is the mistake I am doing here? Thanks In Advance
Please convert string to UIImage like this:
imageview.animationImages = NSArray(array: ["backGround4.jpeg","backGround3.jpeg","backGround.jpeg","16.jpeg","23.jpeg","backGround1.jpeg"].map({ (string) -> UIImage in
UIImage(named: string)! })) as? [UIImage]