【发布时间】:2020-06-29 12:41:51
【问题描述】:
我已经访问过这个答案并且the present method proposed here 不起作用(不再起作用了?)。当我使用 UIViewControllerRepresentable 然后将其显示为工作表时,它看起来非常糟糕:
如果我使用overlay,它看起来就像我想要的那样,但overlay 不能从Button 触发。
这是(精简的)代码:
public struct ContentView: View {
@ObservedObject var model: RootViewModel
@State private var tappedDonate = false
public var body: some View {
Button(action: {
tappedDonate = true
}, label: {
Text("Donate")
.frame(width: 300, height: 44, alignment: .center)
})
.frame(width: 300, height: 20, alignment: .center)
.padding()
.background(Color.black)
.foregroundColor(.white)
.cornerRadius(22)
.sheet(isPresented: $tappedDonate) {
ApplePayWrapper(request: model.buildApplePayment())
.background(Color.clear)
}
}
public init(model: RootViewModel) {
self.model = model
}
}
【问题讨论】:
-
您是否找到了更好的方法来做到这一点,即使在 SwiftUI 2 中也是如此?仍然没有这方面的文档或示例。
-
嗨@TruMan1 不,我没有,我已经放弃了这个项目,因为现在生活中同时发生了太多事情。如果您找到更好的解决方案,请告诉我
标签: swiftui uikit applepay passkit