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
Android on Twitter
Android Development Projects
- Reverse Engineering IOS or Android APP by vw7468783vw
- Write an Android application by vinu121280
- Write some Software by vw7468783vw
- Write an Android - iPhone application whith geolocation and video capabilities by akoynadeis
- Fullstack React Native Mobile App for iOS & Android with Node.Js backend by esuite
- Write an iPhone application by errahulka
- Write an Android application by eusuff
- An application which helps people avoid heavy traffic. by janinepatillas28
- Help me with a 5 minute android task by codehelp87
- Mom's Organizer and Family Planner by bjkulkarni