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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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)
}
}
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) } }
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 *