Skip to content

Instantly share code, notes, and snippets.

@dmytro-anokhin
Last active November 19, 2019 04:59
Show Gist options
  • Select an option

  • Save dmytro-anokhin/f10a5baf83f7a93e24864558c560f9c3 to your computer and use it in GitHub Desktop.

Select an option

Save dmytro-anokhin/f10a5baf83f7a93e24864558c560f9c3 to your computer and use it in GitHub Desktop.
struct AnimatedImage: UIViewRepresentable {
let uiImage: UIImage
func makeUIView(context: UIViewRepresentableContext<AnimatedImage>) -> UIImageView {
let imageView = UIImageView(image: uiImage)
imageView.contentMode = .scaleAspectFit
imageView.startAnimating()
return imageView
}
func updateUIView(_ uiView: UIImageView, context: UIViewRepresentableContext<AnimatedImage>) {
uiView.image = uiImage
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment