I’m making a tab bar iphone app and I wanted to have an animated tab bar icon, I can’t find anything that works, it may not be possible, maybe one of you have done something similar?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not sure if you already solved this, or if you no longer need to do it but this is possible in a few ways. You can either completely create your own TabBar from scratch and build in a mechanism for animating the image. Or, as I assume you want to, you could tweak a UITabBarController to do this for you.
In your controller when you first set the items for your tab bar:
Where self is your UITabBarController. Before this you should have already created your UITabBarItems to put onto the tabBar (I will assume you know how to do this, if not let me know), you will need to retain the ones that you want to animate in a property.
OR
if you have several that you want to animate.
So, when you create the set the items on the tab bar, also start a timer, something like
This will mean that the method,
will get hit every 0.2 seconds. Make sure you have defined the method in your interface, either in your .h file or at the top of your .m file. In this method recall,
With a new set of UITabBarItems that have the images that you want for the next frame in your animation, keep a store of what frame of your animation you are on somewhere, probably in a NSUInteger ivar, and then switch between the images in your timer method. This animation will look a bit like a flick book animation.
Hope this helps, if not let me know and I’ll see what I can do 🙂