我使用一個小圖標作爲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 –