views:

203

answers:

1

In the iPod app on the iPhone there is a UIBarButtonItem in the upper right toolbar that flips between the song and track listings for the album. When you select the button, the button itself does a flip animation.

Is there a way to do this with:

CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];

[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:[self superview] cache:YES];

Do I need to make a UIBarButtonItem with initWithCustomView vs. initWithImage to achieve this?

A: 

The UIBarButtonItem is not a child of any UIView class, therefore cannot be animated. Such animations (as if Apple's Maps or iPod) are, probably, private APIs.

However, a rough workaround this is creating a UIBarButtonItem using initWithCustomView, and then animate the flip inside that view. However, this might be quite cumbersome - you'll need to provide your own border graphics for the button.

Hope this was helpful, Paul

Pawel