点击 UIToolBar 中的按钮
我有一个自定义 UIToolBar,左侧有一个按钮(图像),右侧有一个文本。当我点击按钮时,只有用于按钮的图像是可点击的,而不是工具栏的整个左侧部分。我是否需要有一个覆盖整个部分的图像才能使整个部分变得清晰?或者 UIToolBar 是否提供了任何方法来使整个项目可点击?
下面是在我的自定义类子类化 UIToolBar 中添加这些项目的代码:
[self setItems:[NSArray arrayWithObjects:AddBarButton, FlexibleSpaceBarButton, TextBarItem, nil]];
I have a custom UIToolBar with an button(image) on left and a text on right. When I tap on the button, only the image which I used for the button is tappable and not the entire left section of the toolbar. Do I need to have a image which covers the entire section to make the entire section tappale? Or is there any way which UIToolBar provides to make the entire item tappable?
Below is the code to add these items in my custom class subclassing UIToolBar:
[self setItems:[NSArray arrayWithObjects:AddBarButton, FlexibleSpaceBarButton, TextBarItem, nil]];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您添加按钮时......只有该按钮是可点击的。要执行您想要的操作,您可以向视图添加手势识别器并以这种方式响应点击:
当然,只有当您有一个包含按钮的“子视图”时,这才有效。
When you add a button ... only the button is tap-able. To do what you want, you could add a gesture recognizer to the view and respond to taps that way:
Of course, this will only work if you have a "subview" that is containing your button.