【问题标题】:UIBarButton Tappable area is too much [closed]UIBarButton 可点击区域太多[关闭]
【发布时间】:2013-03-12 05:19:57
【问题描述】:

我有一个从 NIB 添加的 UIBarButtonItem。它的宽度是 33。但是那个 BarButton 的可点击区域太大了。即外部宽度,我们也可以点击该按钮。如何减少等于 UIBarButton 宽度的可点击区域。 提前致谢。

【问题讨论】:

  • 把你的代码放在我的朋友圈。
  • 如果您已为该按钮分配了一些图像,则将其删除并检查其“可点击区域”...
  • 我刚刚从笔尖添加了 uibarbutton 并给出了图像。我什么也没做。但在那个按钮之前我添加了灵活空间
  • @NitinGohel,这里的编码不是pblm,OP将UIBarButton添加到xib

标签: iphone ios xcode ios5 uibarbuttonitem


【解决方案1】:

UIBarButtonItem 默认有一个覆盖。无法使用标准 UIBarButtonItem 限制额外的可点击区域。更好的方法是使用一个看起来像 UIBarButtonItem 的普通按钮。

【讨论】:

  • 谢谢巴努。无论你说什么都是对的,但为此我需要设计师,今天我没有设计师,所以为了快速修复,我在我的 UIBarButtonItem 按钮旁边添加了 1 个隐藏的 UIBarButtonItem,使用它来解决我的问题。我知道它不是完美的解决方案,但对于 nw,只有我能做到。
【解决方案2】:

默认情况下。不能减少 UIBarButton 的可点击区域。

但我总是通过向 UIView 添加一个带有 UIBarButton 自定义图像的 UIButton 并将该 UIButton 的 x、y 坐标更改为 UIBarButton 的框架来解决这个问题,并注意 UIButton 应该在子视图中UIView 不在标签栏中。

【讨论】:

    【解决方案3】:

    试试这个:

    1. 获取 UIView 的对象
    2. 在该 UIView 对象中创建和添加 UIButton 对象
    3. 将该 UIView 对象设置为导航项的标题视图。

    [self.navigationController.navigationItem setTitleView:viewobj];

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-26
      • 1970-01-01
      • 1970-01-01
      • 2016-08-19
      • 1970-01-01
      • 1970-01-01
      • 2021-05-18
      相关资源
      最近更新 更多