Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save aheze/f4e0adde2a9adf1a307bf8649c5a72a0 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")!]
imageView.animationImages = imagesToAnimate
imageView.animationDuration = 1
/// set to -1 for infinite animation
imageView.animationRepeatCount = -1
imageView.startAnimating() ///stop animation with `imageView.stopAnimating()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment