问题描述
我们有一个父级 Split
视图( NSSplitView
)和两个子视图, Content
和 SideBar
(侧边栏在右侧)。
We have a parent Split
view (NSSplitView
), and two subviews, Content
and SideBar
(the sidebar is on the right).
切换 SideBar
视图的最佳可可友好方式?
What would be the optimal Cocoa-friendly way to toggle the SideBar
view?
- 我真的很喜欢它,如果建议的解决方案包括动画
- 我真的不需要任何与外部插件等相关的建议(例如BWToolkit)
提示:我一直在尝试这样做,但是仍然存在隐藏NSSplitView分隔符的问题。我该怎么做,同时隐藏它呢?
HINT : I've been trying to do that, but still I had issues hiding the divider of the NSSplitView as well. How could I do it, while hiding it at the same time?
推荐答案
这是一个相当不错的教程,展示了如何执行此操作:。
Here's a pretty decent tutorial that shows how to do this: Unraveling the Mysteries of NSSplitView.
隐藏分隔符是通过NSSplitView的委托方法 splitView:shouldHideDividerAtIndex:。
Hiding the divider is done in NSSplitView's delegate method splitView:shouldHideDividerAtIndex:.
如果您不喜欢NSSplitView的方式,则必须自己改变帧大小的动画。
You will have to animate the frame size change yourself if you don't like the way NSSplitView does it.
这篇关于如何切换NSSplitView subView的可见性+隐藏窗格拆分器分隔线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!