NSToolbarFlexibleSpaceItem is constraint to NSSplitViewItem in Swift

余生长醉 提交于 2019-12-12 16:08:33

问题


Almost all macOS official apps have this toolbar's feature which the NSToolbarItem flexible space is constraint to NSSplitViewItem view. I first thought maybe there are 3 different sections on NSToolbar. But it just ONE toolbar. You can open Notes app and customize the toolbar.

  • The first flexible space is detected and moved along with first split view item.
  • The second flexible space is detected and moved along with the second split item.
  • The rest will be just normal flexible spaces.
  • If there only two flexible spaces, the second will act as normal flexible space. The same thing applies to one and or flexible space.

I guess this is how Apple configure the flexible space items.

I found this JWToolbarAdaptiveSpaceItem but it's removable and it cannot be replaced with flexible space item like Note apps does.

There is another stackoverflow's question (I couldn't find it now) asked about this but the answer is adding fake views and buttons which is not NSToolbar.

Thus, does anyone know how to achieve this?

(Sorry about my English)

来源:https://stackoverflow.com/questions/39625942/nstoolbarflexiblespaceitem-is-constraint-to-nssplitviewitem-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!