本文介绍了隐藏UIToolbar UIBarButtonItems的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIToolbar,我使用IB设置了三个按钮,左,中,右。在某些情况下,我不想显示中间按钮。有人知道如何隐藏UIToolBar内的特定按钮吗?没有隐藏属性,我只能找到setEnable,但这仍然会留下按钮,让用户想知道它的用途是什么。我想只在实际有用的情况下显示它。

I have a UIToolbar that I set up using IB with three buttons, left, middle and right. In some situations I would like to not display the middle button. Does anybody know of a way to hide a specific button on inside a UIToolBar? There is no hide property, all I can find is setEnable but this still leaves the button causing users to wonder what its purpose is. I would like to only display it in situations that it actually has a use.

提前致谢!

推荐答案

-(void)setItems:(NSArray *)items animated:(BOOL)animated

您可以使用当前项目获取属性,然后只删除你不想显示的那个,并传入新的 NSArray

You can get the current items using the items property, then just remove the one you don't want to show and pass in the new NSArray.

正如您所看到的,您还可以对其进行动画处理以使用户清楚。

As you can see, you can also animate it to make it clear to the user.

这篇关于隐藏UIToolbar UIBarButtonItems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:26