我有一个 NavigationVeiw
,其导航栏的尾部有一个 ToolbarItem
。
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {}, label: {
Text("Button")
})
}
}
navigationBarItems(leading:trailing:)
已经过时,因此我正在使用带有navigationBarTrailing
位置的toolbar(content:)
。- Apple
我在按钮上使用了contextMenu。
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(action: {}, label: {
Text("Button")
})
.contextMenu(menuItems: {
Text("Menu Item 1")
Text("Menu Item 2")
Text("Menu Item 3")
})
}
}
它不够敏感。你需要用力按才能呈现它。我需要像iOS相片应用程序的添加按钮一样只需单击即可呈现它。它可以通过单击展示。
如何通过单击(而非按压)显示菜单?
Image(systemName: "plus")
的按钮很难点击!如何解决这个问题? - LetsGoBrandon.frame(maxWidth: .infinity, maxHeight: .infinity)
或.contentShape(Rectangle())
,并将其放置在Image
上方。 - lorem ipsum.padding()
,但问题是它显然向左移动,看起来不好。 - LetsGoBrandon