问题描述
我的工具栏中有一个UiBarButton项.我需要在UiBarButton.没有 setUserInteractionEnabled 属性.当我隐藏它时,没有适当的可见性.有人可以告诉我如何禁用UIbarbutton的用户触摸交互而不禁用它吗?
i have a UiBarButton item in my Toolbar.i need to deactivate the user touch interaction inUiBarButton. there is no setUserInteractionEnabled property to it. when i am hiding it there is no proper visibility .can any one tell me that how can i disable user touch interaction of a UIbarbutton without disabling it?
推荐答案
要在UIToolBar中具有标题,请将UIBarButtonItem添加到工具栏,然后将其customView属性设置为UILabel.然后,您可以设置标签的文本并且没有任何突出显示等内容.
To have a title in a UIToolBar, add a UIBarButtonItem to your toolbar and then set its customView property to a UILabel. You can then set the text of the label and not have any highlighting, etc.
// In @interface section:
@property (weak, nonatomic) IBOutlet UIBarButtonItem *titleButtonItem;
// In @implementation section:
- (void)viewDidLoad {
...
UILabel *titleLabel = [[UILabel alloc] init];
self.titleButtonItem.customView = titleLabel;
titleLabel.text = @"Some Title Text";
[titleLabel sizeToFit];
...
}
这篇关于如何在不禁用的情况下禁用用户对UIbarbutton的触摸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!