好吧,我想我明白了……
在使用 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
}
请注意,突破行为仍然会发生,但是当这种情况发生时,工具栏会改变外观,并且您不会看到任何像我经历过的丑陋的拆分视图分隔线。希望这对可能遇到此问题的其他人有所帮助。