【问题标题】:How to enlarge the touch area of an UIButton? [duplicate]如何放大 UIButton 的触控区域? [复制]
【发布时间】:2016-03-09 11:11:48
【问题描述】:

如何在不增加背景图片大小的情况下增加(自定义类型)UIButton 的可点击(点击)区域

【问题讨论】:

标签: ios objective-c uibutton


【解决方案1】:

如果您使用图标在 UIbutton 中进行设置。然后使用 3 种尺寸的图像。喜欢

  xyz.png
  xyz@2x.png
  xyz@3x.png

并在图像字段中设置图像xyz.png而不是在背景图像中。然后增加按钮的大小。它将增加按钮的大小而不是图像大小。

【讨论】:

    【解决方案2】:

    最简单的方法——改变 contentEdgeInsets 属性值

    button.contentEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
    

    【讨论】:

    • 你确定我们必须给出正值来增加命中区域吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-26
    相关资源
    最近更新 更多