Hey !
I know its been a while, I am qui busy at Moment Factory right now. Those guys are geniuses. Anyway, I wanted to share with you, if you don’t already know it, how to animate anything that uses a UIImage aka. UIImageView, UIButton, etc…
To create an animated UIImage, include in you project a folder that contains your animation with a PNG for each frame. The files needs to be named like this:
- WhatEverNameYouWant-1
- WhatEverNameYouWant-2
- WhatEverNameYouWant-3
- WhatEverNameYouWant-4
- …
I strongly recommend not to include these in an asset file, if you try you’ll quickly understand why.
Then you create a UIImage :
1 |
let animatedImage = UIImage.animatedImageNamed("WhatEverNameYouWant-", duration: 5) |
You can the use it with a UIButton like you would with any other UIImage :
1 |
button1.setImage(animatedImage, forState: .Normal) |
That’s it ! Have fun animating you apps !!
MAB