在NSButton上扩展点击/点击区域

时间:2019-06-19 19:41:57

标签: macos cocoa appkit nsbutton

我试图将NSButton上的可单击区域增大(macOS应用程序)。

我已经在iOS中使用UIButton做到了:

override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
    let area = CGRect(
        x: self.bounds.origin.x - 5.0,
        y: self.bounds.origin.y - 20.0,
        width: self.bounds.size.width + 10.0,
        height: self.bounds.size.height + 40.0
    )
    return area.contains(point)
}

使用NSButton是否可以实现类似的方式? point()函数在Cocoa / AppKit中不存在。 我已经尝试过hitTest()但无法弄清楚。

0 个答案:

没有答案