如果我们使用NSTrackingArea
对于一些特定区域,然后我们就可以实现这样的方法来改变默认光标:
-(void)cursorUpdate:(NSEvent *)theEvent {
[[NSCursor resizeLeftCursor] set];
}
我实现自定义调整为NSWindow
,它使用NSBorderlessWindowMask
。 并希望使用本地狮子的两个箭头光标。 但是,这种类型的游标不存在中NSCursor API 。
我能得到某种方式从代码,本地游标?
或者,也许我必须用手(不是一个好主意)重绘他们?
WebKit的包含长得一模一样的系统所使用的游标,在以下目录中的图片:
/System/Library/Frameworks/WebKit.framework/Versions/Current/Frameworks/WebCore.framework/Resources/
...例如,文件“northWestSouthEastResizeCursor.png”。
目前WebKit中的那些不可视网膜分辨率不幸的是,在看
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Resources/cursors
你会发现调整光标的PDF版本。
下面是一些示例代码加载向量为基础的(并因此能够视网膜)从HIServices.framework光标:
NSString *cursorName = @"resizenortheastsouthwest";
NSString *cursorPath = [@"/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Resources/cursors" stringByAppendingPathComponent:cursorName];
NSImage *image = [[NSImage alloc] initByReferencingFile:[cursorPath stringByAppendingPathComponent:@"cursor.pdf"]];
NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[cursorPath stringByAppendingPathComponent:@"info.plist"]];
NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint([[info valueForKey:@"hotx"] doubleValue], [[info valueForKey:@"hoty"] doubleValue])];
请注意,我不知道这是否工作在沙盒应用程序。
有建立这样光标无证方法。 下面是一个例子:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
if ([NSCursor respondsToSelector:@selector(_windowResizeNorthSouthCursor)])
{
self.resizeUpDownCursor = [NSCursor performSelector:@selector(_windowResizeNorthSouthCursor)];
}
else
{
self.resizeUpDownCursor = [NSCursor resizeUpDownCursor];
}
#pragma clang diagnostic pop
下面是在MacOS上塞拉利昂无证游标的完整列表:
[NSCursor _windowResizeEastCursor]
[NSCursor _windowResizeWestCursor]
[NSCursor _windowResizeEastWestCursor]
[NSCursor _windowResizeNorthCursor]
[NSCursor _windowResizeSouthCursor]
[NSCursor _windowResizeNorthSouthCursor]
[NSCursor _windowResizeNorthEastCursor]
[NSCursor _windowResizeNorthWestCursor]
[NSCursor _windowResizeSouthEastCursor]
[NSCursor _windowResizeSouthWestCursor]
[NSCursor _windowResizeNorthEastSouthWestCursor]
[NSCursor _windowResizeNorthWestSouthEastCursor]
[NSCursor _zoomInCursor]
[NSCursor _zoomOutCursor]
[NSCursor _helpCursor]
[NSCursor _copyDragCursor]
[NSCursor _genericDragCursor]
[NSCursor _handCursor]
[NSCursor _closedHandCursor]
[NSCursor _moveCursor]
[NSCursor _waitCursor]
[NSCursor _crosshairCursor]
[NSCursor _horizontalResizeCursor]
[NSCursor _verticalResizeCursor]
[NSCursor _bottomLeftResizeCursor]
[NSCursor _topLeftResizeCursor]
[NSCursor _bottomRightResizeCursor]
[NSCursor _topRightResizeCursor]
[NSCursor _resizeLeftCursor]
[NSCursor _resizeRightCursor]
[NSCursor _resizeLeftRightCursor]