是否可以使用Core Animation来淡出一个UIBarButtonItem? [英] Is it possible to use Core Animation to fade out a UIBarButtonItem?

查看:88
本文介绍了是否可以使用Core Animation来淡出一个UIBarButtonItem?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇,是否可能以某种方式交织核心动画来给出一个UIBarButtonItem的淡出?我有一个tableView,我用两个不同的数据源。一旦特定的数据源被触发,我想淡出当前的UIToolBar选项并淡入新的选项。

I'm curious, is it possible to somehow intertwine Core Animation to give a "fade out" of a UIBarButtonItem? I have a tableView which I represent with two different data sources. Once a particular data source gets triggered, I'd like to fade out the current UIToolBar options and fade in new ones.

感谢您指向正确的方向。 / p>

Thanks for pointing me in the right direction.

推荐答案

如果你真的使用UIToolbar(注意小写的b)而不是UINavigationBar,简单的方法来更改按钮,并让过渡自动褪色,而不会丢弃到Core Animation。

If you really are using a UIToolbar (note the lower-case "b") and not a UINavigationBar, there is a very easy way to change the buttons and have the transition automatically fade without dropping to Core Animation.

如果你使用的是Interface Builder,你需要一个工具栏在您的代码。创建一个IBOutlet属性并将工具栏链接到IB:

If you're using Interface Builder, you'll need a reference to the toolbar in your code. Create an IBOutlet property and link the toolbar to it in IB:

@property (nonatomic, retain) IBOutlet UIToolbar *toolbar;

这将允许您以self.toolbar引用UIToolbar。然后,创建新的按钮并将它们添加到NSArray并将其传递到 - [UIToolbar setItems:animated:]方法,如下所示:

This will allow you to reference the UIToolbar as self.toolbar. Then, create your new buttons and add them to an NSArray and pass this to the -[UIToolbar setItems:animated:] method as follows:

UIBarButtonItem *newItem = [[[UIBarButtonItem alloc] 
                                initWithBarButtonSystemItem:UIBarButtonSystemItemDone 
                                target:self 
                                action:@selector(handleTap:)] autorelease];
NSArray *newButtons = [NSArray arrayWithObjects:newItem, nil];
[self.toolbar setItems:newButtons animated:YES];

这篇关于是否可以使用Core Animation来淡出一个UIBarButtonItem?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆