我使用一个小图标作为UIbutton的图像。我想增加图标的命中区域,这样IBaction就会被调用,而不需要精确点击小图标。我在这里发现了类似的问题,解决方法是调整插入内容,但这似乎不适用于我,但命中区域仍然相同。增加一个按钮的命中区域
smallButton.imageEdgeInsets = UIEdgeInsets(top: -100.0, left: -100.0,bottom: -100.0, right: -100.0)
smallButton.contentEdgeInsets = UIEdgeInsets(top: -100.0, left: -100.0, bottom: -100.0, right: -100.0)
增加按钮的大小的宽度双图像图标 –
https://stackoverflow.com/questions/42181550/how-can-i-expand-the-hit-area-of-a-specific-uibutton的-in-swift https://stackoverflow.com/questions/31056703/how-can-i-increase-the-tap-area-for-uibutton –