SwiftUI、macOS。
当我尝试这样做时:
ToolbarItem (placement: .navigationBarTrailing) {
// content
}
Run Code Online (Sandbox Code Playgroud)
我收到编译错误:“navigationBarTrailing”在 macOS 中不可用
那么如何将内容放置在菜单栏的右侧呢?
我假设您指的是工具栏(因为 macOS 应用程序主菜单栏是唯一的,不允许将项目放在右侧 - 您需要NSStatusItem为此进行操作)。
因此,对于工具栏,我相信您可以使用confirmationAction放置将项目强制放置在尾随(右侧)位置。请参阅下面的苹果文档:
/// The item represents a confirmation action for a modal interface.
///
/// ...
///
/// In macOS and in Mac Catalyst apps, the system places
/// `confirmationAction` items on the trailing edge
/// in the trailing-most position of the sheet and gain the apps accent
/// color as a background color.
///
/// ...
///
public static let confirmationAction: ToolbarItemPlacement
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1602 次 |
| 最近记录: |