iOS如何实现扩大按钮的点击范围

import UIKit

class ExtendableAreaButton: UIButton {

    var hitOffset = UIEdgeInsetsZero

    override func pointInside(point: CGPoint, withEvent event: UIEvent?) -> Bool {
        guard hitOffset != UIEdgeInsetsZero && enabled && !hidden else {
            return super.pointInside(point, withEvent: event)
        }
        return UIEdgeInsetsInsetRect(bounds, hitOffset).contains(point)
    }
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *