Quickly implement the Apple Pay button in SwiftUI
Get Started | Examples | Customize | Install |
Install iPages
Add iPaymentButton
to your project
import SwiftUI
import iPaymentButton
struct ContentView: View {
var body: some View {
iPaymentButton(action: {
// Add your custom payment code here
})
}
}
iPages
Use our built-in applePayDemo()
to demo a purchase experience.
import SwiftUI
import iPaymentButton
import iGraphics
struct ContentView: View {
var body: some View {
iGraphicsBox().stack(3)
iPaymentButton(action: {
iPaymentButton.applePayDemo()
// Add your custom payment code here
})
}
}
import SwiftUI
import iPaymentButton
import iGraphics
struct ContentView: View {
var body: some View {
iGraphicsView(.first)
iPaymentButton(type: .support, style: .whiteOutline, action: {
iPaymentButton.applePayDemo()
// Add your custom payment code here
})
}
}
iPaymentButton
has one required parameter: an action to execute on button tap. iPaymentButton
supports several custom initializers and one custom modifier.
Example: Change the text, style and corner radius with the following code block:
iPaymentButton(type: .support, style: .whiteOutline, action: { } )
.cornerRadius(25)
Use our exhaustive input list to customize your views.
Modifier or Initializer | Description |
---|---|
type: PKPaymentButtonType = .buy |
The text written on the button. 🆒 |
type: PKPaymentButtonStyle = .black |
The color that the button should be. 🎨 |
action: @escaping () -> Void |
The action to be performed when the user taps the button. 🎬▶️ |
.cornerRadius(radius: CGFloat) -> iPaymentButton |
Modifies the corner radius of the payment button ⬛️⚫️. To remove the rounded courners, set this value to 0.0 0️⃣👌. The default value is set to 4.0 🍀. |
Use the Swift package manager to install. Find instructions here😀