您想使用 StoreKit,特别是
SKOverlay
您可以在这里阅读更多相关信息
在 UIViewController 中的 UIKit 中,您想在其中显示它,可以使用以下代码:
func displayOverlay() {
guard let scene = view.window?.windowScene else { return }
let config = SKOverlay.AppConfiguration(
appIdentifier: "The iTunes identifier of another app.",
position: .bottom
)
let overlay = SKOverlay(configuration: config)
overlay.present(in: scene)
}
在 SwiftUI 中你可以通过以下方式使用它:
struct ContentView: View {
@State private var presentingAppStoreOverlay = false
var body: some View {
Button {
presentingAppStoreOverlay.toggle()
} label: {
Text("Show SKOverlay")
}
.appStoreOverlay(isPresented: $presentingAppStoreOverlay) {
SKOverlay.AppConfiguration(
appIdentifier: "The iTunes identifier of another app.",
position: .bottom
)
}
}
}