相关疑难解决方法(0)

如何在仅 SwiftUI 的项目中正确呈现 PKPaymentAuthorizationViewController?

我已经访问过这个答案,这里提出present方法不起作用(不再?)。当我使用 aUIViewControllerRepresentable然后将其显示为工作表时,它看起来非常糟糕:

屏幕截图 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
    } …
Run Code Online (Sandbox Code Playgroud)

uikit passkit applepay swiftui

5
推荐指数
1
解决办法
297
查看次数

标签 统计

applepay ×1

passkit ×1

swiftui ×1

uikit ×1