我试图在光标经过视图时更改光标,但我想我没有正确编码它,因为它不工作。
我有一个 appcontroller 类,在它的 .m 文件中我有这个
- (void) awakeFromNib {
//set up the cursors
NSCursor * handCursor = [NSCursor closedHandCursor];
//make a box
Box* newBox = [[Box alloc] initWithFrame:NSMakeRect(10.0, 10.0, 100.0, 100.0)];
//set up the rect for the cursor change
NSRect rectForCursor = [newBox frame];
[newBox addCursorRect:rectForCursor cursor:handCursor];
//add box to main win
[[mainWin contentView] addSubview:newBox];
}