#Working with SwiftUI
The SDK also provides some ways to show a paywall using SwiftUI.
#createPaywall
func createPaywall(access: Access, pageType: String, percent: Int?) -> some View
Presents a paywall. The paywall will print above the View on which this modifier is applied.
example.swift
import AccessIOS
struct MyView: View {
var access: Access
init() {
access = Access(key: "<your_app_id>")
}
var body: some View {
VStack {
Text("first paragraph")
Text("second paragraph")
.createPaywall(access: access, pageType: "free", percent: 80)
}
}
}
#createPaywall
func createPaywall(pageType: String) -> some View
Presents a paywall in custom mode
example.swift
import AccessIOS
struct MyView: View {
var access: Access
init() {
access = Access(key: "<your_app_id>")
}
var body: some View {
VStack {
Text("first paragraph")
Text("second paragraph")
access.createPaywall(pageType: "free")
}
}
}
This method returns a View object containing the paywall content after its been rendered.
⚠️ The resulting view can be moved or scaled down in width, but will automatically redraw itself to a height that can fit its content. Any attempt at height modification might break its layout.