我正在尝试在我正在构建的 iPhone 应用程序中使用垃圾桶动画。我知道我需要帮助的功能是私有(private) API,但该应用程序将是内部的。
根据iPhoneDevWiki at the toolbar page您可以使用 [UIToolbar animateToolbarItemIndex:duration:target:didFinishSelector:];
激活垃圾桶打开动画。
经过无数个小时的尝试使用此方法后,我无法让它发挥作用。到目前为止,我已将其更改为以下内容:[toolbar animateToolbarItemIndex:1 period:1.0 target:self didFinishSelector:@selector(done:)];
。
toolbar
是我使用 CGRectMake
以编程方式创建的 UIToolbar
的名称。
我的垃圾桶按钮图像是 1,因为它是第二个按钮。
我尝试将 self
和 nil
放入 target
但它不起作用。
didFinishSelector
只是链接到 -(void)done:(id)sender;
。
如果我将 animateToolbarItemIndex
更改为不存在的内容,控制台会显示它不存在。对我的错误有什么想法吗?
最佳答案
垃圾桶动画适用于一系列图像,每个图像的盖子关闭/打开的程度都比较大。所以你会做这样的事情:
UIImageView* trashCan = [[UIImageView alloc] initWithFrame:self.view.frame];
trashCan.animationImages = [NSArray arrayWithObjects:UIIMAGES, nil];
trashCan.animationDuration = 1.00;
trashCan.animationRepeatCount = 1;
[trashCan startAnimating];
[self.view addSubview:trashCan];
如果您有谷歌,我相信您能够找到要使用的垃圾桶图像。
关于iPhone 垃圾桶吸动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5736626/