Basic iOS animation
Sometimes you may need to display short animations in your applications like funny GIFs. The problem with GIFs is that they have only 256 colors and poor transparency. You can consider using PNGs, but basically that type of image doesn't support animations. So what can you do to push the advantage of PNGs (great lossless compression, alpha channels, various coloring schemes, etc.)?
In your iOS app you can simply define the animation frame images of PNGs and tell the app to use these frames in an animation. Just that simple. I'll now show you how to do that.
I will use JPGs for this time but the same works for PNGs as well. You need to drag the frame images into your project, like this:
After this you will need an UIImageView and an NSArray for the frames:
I am using an IBOutlet which is linked to an UIImageView in the Interface Builder.
For testing purposes, my implementation look as follows:
When the view is loaded, it populates the frame array with the images in order. Here you can set such properties like the animation duration which is for the whole animation with all the images in the array. If you would like to set the repeat count to infinite, you should set the corresponding property to 0. In this example the animation starts immediately when the view appears and runs only once.
I've made an animation like this with the code above:
For the android version of the code above you can find examples at http://developer.android.com/g
Feel free to rewrite the code and use it as needed.
New tutorials from Helloandroid
Recent Apps
Android on Twitter
-
@Idevicegazette (iDevice Gazette)
GSM-to-Skype bridge lets you lose those roaming fees http://bit.ly/lbRJeh #android
8 years 30 weeks ago -
@tommy_banane (tom b.)
RT @AndroidFavorite: #Android New Desktop Android Market Is Live, Adds Several New Features http://zorr0.nl/lFwXNz
8 years 30 weeks ago -
@dwilliams5 (Dennis Williams)
just completed a runtastic run of 3.02 km in 40 min 11 s with #runtastic #Android App: http://tinyurl.com/5tvrpe3
8 years 30 weeks ago -
@S_Pinz (Spinz!)
RT @Androidheadline: Out of box #LG Optimus 3D got Quadrant 2420 score. Thanks @blink_c #io2011 #android http://twitpic.com/4whkdz
8 years 30 weeks ago -
@tayaitapps (Taya IT)
Next Google TV Looks A Lot Like Android http://t.co/dvlTim3 via @alleyinsider #google #apple #android #tv #honeycomb
8 years 30 weeks ago
Poll
Useful resources
Android Development Projects
- Voice Dating App
- Calendar Widget/ App
- I need a game dev
- Mobile App (Food & Social)
- voice chat between 2 mobiles using bluetooth or wifi-direct/multipeer
- Random Video Chat/Voice Calling App
- Build me an app/website
- Send and receive SMS ionic App
- Android Studio - Preciso de um app simples IPTV -- 2
- Android Studio - Preciso de um app simples IPTV