我正在查看 Apple Reminders 应用程序,并希望在 iPhone 上构建相同的弹出式 View 。这是我指的屏幕:
所以,我可以使用 popover 修饰符在 iPad 上呈现类似 UI 的弹出框。
struct ContentView: View {
// 1.
@State var isPopoverPresented = false
var body: some View {
// 2.
Button(action: {
self.isPopoverPresented = true
}) {
Text("Some content")
}
// 3.
.popover(isPresented: $isPopoverPresented) {
Text("Popover is Presented")
.font(.largeTitle)
.frame(width: 200, height: 300)
}
}
}
但是,当该代码在 iPhone 上运行时,弹出框会变成从底部向上弹出的全屏模式。
我想知道是否有一种本地方式来构建类似于提醒应用程序中显示的屏幕,或者该屏幕是否是 iPhone 上具有自定义布局逻辑的自定义 View ?
最佳答案
关于SwiftUI:在 iPhone 上显示弹出框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71559397/