在 iPhone 上的 iPod 应用程序中,右上角的工具栏中有一个 UIBarButtonItem,可在专辑的歌曲和轨道列表之间切换。当您选择按钮时,按钮本身会执行翻转动画。
有没有办法做到这一点:
CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:nil context:context]; [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:[self superview] cache:YES];
我是否需要使用 initWithCustomView 与 initWithImage 制作 UIBarButtonItem 来实现此目的?
最佳答案
UIBarButtonItem 不是任何 UIView 类的子类,因此不能设置动画。此类动画(就像 Apple 的 map 或 iPod)可能是私有(private) API。
但是,一个粗略的解决方法是使用 initWithCustomView 创建一个 UIBarButtonItem,然后在该 View 内设置翻转动画。但是,这可能非常麻烦 - 您需要为按钮提供自己的边框图形。
希望对您有所帮助, 保罗
关于iphone - 如何制作 UIBarButtonItem 动画翻转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2785363/