Skip to content

Instantly share code, notes, and snippets.

@licvido
Created February 3, 2015 23:18
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save licvido/bc22343cacfa3a8ccf88 to your computer and use it in GitHub Desktop.
Save licvido/bc22343cacfa3a8ccf88 to your computer and use it in GitHub Desktop.
SWIFT: Fade when changing UIImageView's image
let toImage = UIImage(named:"image.png")
UIView.transitionWithView(self.imageView,
duration:5,
options: .TransitionCrossDissolve,
animations: { self.imageView.image = toImage },
completion: nil)
@ixeau
Copy link

ixeau commented Nov 13, 2016

great and easy solution, thank you!

@tjarbo
Copy link

tjarbo commented May 22, 2017

Very nice , but it should get an upgrade for swift3

@halgatewood
Copy link

Swift 3:

let toImage = UIImage(named:"image.png")
UIView.transition(with: self.imageView,
                          duration:5,
                          options: .transitionCrossDissolve,
                          animations: { self.imageView.image = toImage },
                          completion: nil)

@decodeveronikaa
Copy link

Thanks, it works perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment