Dock이 커서 변경 사항을 덮어 쓰기 때문입니다. 커서를 변경하기 위해 반복적으로 발생하는 타이머를 설정하면됩니다. 먼저 커서를 변경 할 준비가되면, 당신은 반복적으로 불
에게 타이머를 스타와 그것을 할 필요가 당신이 그런 다음 customCursor
func changeCursor() {
/* Code here to create custom cursor */
customCursor.set()
}
을 커서를 변경 한 다음 설정 할 수있는 방법을 만들
//cursorTimer is an NSTimer object that you need to keep track of
self.cursorTimer = NSTimer.scheduledTimerWithTimeInterval(0.001, target:self, selector: "changeCursor", userInfo: nil, repeats: true)
그리고이 완료되면, 당신은 타이머를 무효화 할 수
self.cursorTimer.invalidate()
또한 앱이 가장 많이 사용되는 경우에만 작동합니다. 다른 사용자가 command + tab 키를 누르면 앱에서 더 이상 커서를 설정할 수 없습니다. 앱이 백그라운드에서 커서를 제어 할 수있게하려면 비공개 API를 사용해야하므로 Mac App Store는 없습니다. 당신의 브리지 헤더에서
는 다음과 같은 코드를 추가 할 수 있습니다
typedef int CGSConnectionID;
CGError CGSSetConnectionProperty(CGSConnectionID cid, CGSConnectionID targetCID, CFStringRef key, CFTypeRef value);
int _CGSDefaultConnection();
그리고 AppDelegate에 당신이 applicationDidFinishLaunching
let propertyString = CFStringCreateWithCString(kCFAllocatorDefault, "SetsCursorInBackground", 0)
CGSSetConnectionProperty(_CGSDefaultConnection(), _CGSDefaultConnection(), propertyString, kCFBooleanTrue)
출처
2016-01-17 18:47:16
MAH
이 코드는이 작업을 수행하는 방법을 발견 추가 할 수 있습니까? –
현재 코드에서 커서가 정확히 어떻게 변경 되었습니까? 필자의 경우'NSView' 서브 클래스에서'resetCursorRects' 메소드를 구현하면 (뷰의'bounds'에서'addCursorRect : cursor :'를 호출하는 것만으로도 충분합니다); 커서 모양 자체를 복원합니다. –