更改iPad上的工具栏项目位置
让我们以快捷方式应用程序。
如您所见,工具栏项目在上。
我的代码看起来像这样:
struct ContentView: View {
var body: some View {
NavigationView {
Text("This is a test app.")
.navigationTitle("All Shortcuts")
.toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) {
Button("Select") {
// Do something...
}
Button(action: {
// Do something else...
}) {
Label("Some Other Action", systemImage: "plus")
}
}
}
}
}
}
这是在iPhone上的预期工作,但是在iPad上,工具栏项目出现在工具栏的后端。我希望工具栏项目在iPhone的后端和iPad的领先端,就像快捷应用程序一样。我该如何实现这种行为?
Let's take the Shortcuts app for example.
As you can see, the toolbar items were on .navigationBarTrailing
on iPhone, but it moved to .navigationBarLeading
on iPad.
My code looks like this:
struct ContentView: View {
var body: some View {
NavigationView {
Text("This is a test app.")
.navigationTitle("All Shortcuts")
.toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) {
Button("Select") {
// Do something...
}
Button(action: {
// Do something else...
}) {
Label("Some Other Action", systemImage: "plus")
}
}
}
}
}
}
This works as expected on iPhone, but on iPad the toolbar items appear at the trailing end of the toolbar. I want the toolbar items to be on the trailing end for iPhones and on the leading end for iPads, just like the Shortcuts app. How can I achieve this behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以检查使用的设备类型:
you can check for the used device type: