区域跟踪有一个注意点,示例代码如下:
let track : NSTrackingArea = NSTrackingArea.init(rect: self.middleView.leftView.bounds, options: [.mouseMoved,.activeAlways,.inVisibleRect], owner: self, userInfo: nil)
self.middleView.leftView.addTrackingArea(track)
其中options需要有这个三个参数,eg:[.mouseMoved,.activeAlways,.inVisibleRect]
三个参数必需取之于[mouseEnteredAndExited、mouseMoved、cursorUpdate]、[activeWhenFirstResponder、activeInKeyWindow、activeInActiveApp、activeAlways]和[assumeInside、inVisibleRect、enabledDuringMouseDrag]
网友评论