evgenyneu / moa

An image download extension of the image view written in Swift for iOS, tvOS and macOS.
MIT License
333 stars 45 forks source link

Animate Image after downloading #6

Closed Perjan closed 4 years ago

Perjan commented 8 years ago

Hey guys, is there any way to animate an image after it downloads. More like a subtle opacity change.

How can I do that?

Thanks for the amazing library!

evgenyneu commented 8 years ago

Hi @Perjan, good question. One can use moa.onSuccess property to fade in the image when it arrives. For example:

imageView.moa.onSuccess = { [weak self] image in
  self?.imageView.alpha = 0
  UIView.animate(withDuration: 0.5) { self?.imageView.alpha = 1 }
  return image
}

imageView.moa.url = "https://raw.githubusercontent.com/evgenyneu/moa/master/Graphics/Hunting_Moa.jpg"

Cheers