1

I'm trying to animate a UITabBarItem in my application. I would like to make the image "pulse", to indicate to the user that there is something new.

I've been searching for a while now, but i don't find anything. I will using the animation of UIView, but i can't find a way to access the view of the uitabbaritem. Do you have an idea ? Thanks !

Pramod More
  • 1,220
  • 2
  • 22
  • 51
Gael.D
  • 500
  • 1
  • 5
  • 16
  • 3
    Not to dismiss your idea, but the generally accepted way of indicating that something's new in a particular tab bar item is to adjust its [`badgeValue`](http://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UITabBarItem_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006928-CH3-SW16) property. That gives you the system-standard red circle with a number inside; most iOS users are very familiar with that badge and will associate it with new or actionable items. – Tim Jul 14 '12 at 15:18
  • We'll about to think about that, but we want to notify two differents kinds of events, the badge value give the new products, but not the new private sells information. – Gael.D Jul 16 '12 at 17:13

1 Answers1

3

Well, if you look at UIBarItem (the superclass), there is a UIImage property. If you look at UIImage you will see a "+ (UIImage *)animatedImageWithImages:(NSArray *)images duration:(NSTimeInterval)duration" property.

Thus, I assume (but did not test) that you can create a series of images that when sequenced through will do what you want.

Alternately, you can subclass UIBarButtonItem, and provide your own "setTag:" method so as to intercept that message, and use special values to signal that you want pulsing on and or other states.

That method would get the image properly, the CGImageRef backing it, fiddle with it (color, opacity, whatever), then do a super.image = modified image. Have no idea if this will in fact work but at least may give you some ideas.

David H
  • 40,852
  • 12
  • 92
  • 138
  • That could indeed may work, but that included make a lot of images. The design of the menus is not final yet, so we may need to use a full custom menu components, and adding the pulse will be so a lot more easy to do. – Gael.D Jul 16 '12 at 17:15