禁用NSOutlineView的转出动画

The*_*age 4 macos cocoa objective-c

有没有办法停止NSOutlineView的推出动画.通过"推出",我指的是当项目展开/折叠,孩子向下/向上滑动时发生的动画.

poi*_*tum 8

创建NSOutlineView的子类并抑制动画:

-(void) expandItem:(id)item expandChildren:(BOOL)expandChildren
{
    [NSAnimationContext beginGrouping];
    [[NSAnimationContext currentContext] setDuration:0.0];

    [super expandItem:item expandChildren:expandChildren];

    [NSAnimationContext endGrouping];
}
Run Code Online (Sandbox Code Playgroud)

其他方法是:

– expandItem:
– expandItem:expandChildren:
– collapseItem:
– collapseItem:collapseChildren:
Run Code Online (Sandbox Code Playgroud)