[英]Can NSTrackingSeparatorToolbarItem be used from SwiftUI?
I'm attempting to create a macOS application that has a sidebar, and I'd like to be able to use the new .sidebarTrackingSeparator
toolbar item.我正在尝试创建一个具有侧边栏的 macOS 应用程序,并且我希望能够使用新的.sidebarTrackingSeparator
工具栏项。 However, it's not accessible as part of ToolbarItemPlacement
, and the following code:但是,它不能作为ToolbarItemPlacement
的一部分访问,下面的代码:
NSApp.keyWindow?.toolbar?.insertItem(withItemIdentifier: .sidebarTrackingSeparator, at: 0)
places it, but the item isn't visible.放置它,但该项目不可见。
Is there any way to place a button in the toolbar such that it's visible on top of the sidebar like Xcode's left-collapse item?有没有办法在工具栏中放置一个按钮,使其像 Xcode 的左折叠项一样在侧边栏的顶部可见?
If you want a button on the left side of the sidebarTrackingSeparator
, the index of the separator must be larger the first button.如果你想在sidebarTrackingSeparator
左侧有一个按钮,则分隔符的索引必须大于第一个按钮。 So try to insert the separator with an index of 1 instead of 0.所以尝试插入索引为 1 而不是 0 的分隔符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.