Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 调整拆分视图的大小时,如何避免NSTrackingSeparatorToolbarItem溢出?_Swift_Macos_Appkit_Macos Big Sur - Fatal编程技术网

Swift 调整拆分视图的大小时,如何避免NSTrackingSeparatorToolbarItem溢出?

Swift 调整拆分视图的大小时,如何避免NSTrackingSeparatorToolbarItem溢出?,swift,macos,appkit,macos-big-sur,Swift,Macos,Appkit,Macos Big Sur,我正在开发一个macOS应用程序,我以编程方式添加了NSToolBarItem,以支持新的macOS 11工具栏外观 跟踪分隔符似乎可以正常工作,只要我不将分割视图的大小调整到某个宽度以下,那么分隔符就会断裂,看起来不合适 跟踪分离器按预期工作 当分割视图的大小小于某个宽度时,分隔符会出现。 有没有办法避免这种情况??我知道我可以为分割视图设置最小大小,但是有没有办法使它们保持同步(我不想硬编码最小宽度)??尤其是当用户动态添加工具栏项时 提前谢谢。好的,我想我已经明白了 在使用Mail应用

我正在开发一个macOS应用程序,我以编程方式添加了NSToolBarItem,以支持新的macOS 11工具栏外观

跟踪分隔符似乎可以正常工作,只要我不将分割视图的大小调整到某个宽度以下,那么分隔符就会断裂,看起来不合适

跟踪分离器按预期工作

当分割视图的大小小于某个宽度时,分隔符会出现。

有没有办法避免这种情况??我知道我可以为分割视图设置最小大小,但是有没有办法使它们保持同步(我不想硬编码最小宽度)??尤其是当用户动态添加工具栏项时


提前谢谢。

好的,我想我已经明白了

在使用Mail应用程序时,我注意到一个有趣的行为,即当预览窗格显示NSTrackingSeparatorToolbarItem时,会跟随拆分视图的大小调整,但预览折叠时,工具栏的外观会发生变化,变得像一个静态工具栏。此外,NSTrackingSeparatorToolbarItem保持不变,看起来就像一个普通的工具栏分隔符(您可能会在其他操作系统上找到)

所以我用我的工具栏在IB中玩,发现了我的错误,我的NSWindow将标题栏设置为透明

我取消选中该选项,瞧,我可以复制邮件应用程序的外观和感觉,所有这些都是自动的

在NSWindow中,此属性必须设置为false

@available(macOS 10.10, *)
open var titlebarAppearsTransparent: Bool
当然,工具栏样式应该设置为统一

@available(macOS 11.0, *)
    public enum ToolbarStyle : Int {
    // The default value. The style will be determined by the window's given configuration
    case automatic = 0
    // The toolbar will appear below the window title
    case expanded = 1
    // The toolbar will appear below the window title and the items in the toolbar will attempt to have equal widths when possible
    case preference = 2
    // The window title will appear inline with the toolbar when visible
    case unified = 3
    // Same as NSWindowToolbarStyleUnified, but with reduced margins in the toolbar allowing more focus to be on the contents of the window
    case unifiedCompact = 4
}
请注意,中断行为仍然会发生,但当这种情况发生时,工具栏的外观会发生变化,并且您不会看到任何像我所经历过的丑陋的分割视图分隔线。希望这能帮助其他可能遇到这个问题的人