I have a "two-panel selector" or "shoe box" implemented with an NSSplitView and two NSOutlineViews, one for each split item in the NSSplitView. Basically it looks like this:
[Window Toolbar]
| side | main |
The sidebar can be toggled by
func toggleSidebar() {
self.splitViewItems[0].animator().isCollapsed =
!self.splitViewItems[0].animator().isCollapsed
}
The problem
The animation is not smooth, especially when the "main"'s content are scrolled up below the toolbar (with the translucency effect).
Attempts
I have a customized subclass of NSTableHeaderCell with an overriding draw(withFrame:in:). I noticed the draw(withFrame:in:) method is called (per frame I guess) during the animation.
I also set the headerView of the NSOutlineView to be layer-backed, and set it as:
self.outlineView.headerView!.layerContentsRedrawPolicy = .onSetNeedsDisplay
self.outlineView.headerView!.layerContentsPlacement = .left
Other LayerContentsRedrawPolicys have been tried, not effective to the problem.
macOS's Finder
Finder has a sidebar hiding functionality. The animation is butter smooth. When in the outline mode, the column header has some suspicious transition going on.
Though we can't see how Finder optimized the animation, at least it shows that smooth animation is possible.
Any suggestions or answers will be appreciated.