你如何使UIBarButtonItem动画翻转?

And*_*row 5 iphone cocoa-touch objective-c uikit

在iPhone上的iPod应用程序中,右上方工具栏中有一个UIBarButtonItem,可以在专辑的歌曲和曲目列表之间翻转.选择按钮时,按钮本身会执行翻转动画.

有没有办法做到这一点:

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

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

我是否需要使用initWithCustomView与initWithImage创建一个UIBarButtonItem来实现这一目标?

Paw*_*wel 8

UIBarButtonItem不是任何UIView类的子节点,因此无法设置动画.这些动画(如Apple的地图或iPod)可能是私有API.

但是,一个粗略的解决方法是使用initWithCustomView创建一个UIBarButtonItem,然后为该视图内的翻转设置动画.但是,这可能非常麻烦 - 您需要为按钮提供自己的边框图形.

保罗,希望这很有帮助