Skip to content

Instantly share code, notes, and snippets.

@aheze
Last active June 4, 2020 19:05
Show Gist options
  • Select an option

  • Save aheze/74418b615eefde47ff1d8a3888ee89ee to your computer and use it in GitHub Desktop.

Select an option

Save aheze/74418b615eefde47ff1d8a3888ee89ee to your computer and use it in GitHub Desktop.
/// the UIImageView that will hold the animation
let imageView = UIImageView()
imageView.frame = CGRect(x: 100, y: 100, width: 150, height: 150)
view.addSubview(imageView)
/// the images that will be animated
/// images are stored in the Resources folder of this playground
let imagesToAnimate = [UIImage(named: "0")!, UIImage(named: "1")!, UIImage(named: "2")!]
let animationImages = UIImage.animatedImage(with: imagesToAnimate, duration: 1)
/// set the imageView's images to the animation image
imageView.image = animationImages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment