iOS SDK customization guide
Customization for the pre-built UI
CheckoutTheme class
Customize CardViewController
with the CheckoutTheme
class.
// Apply customizations to CheckoutTheme.CheckoutTheme.primaryBackgroundColor = .purpleCheckoutTheme.secondaryBackgroundColor = .magentaCheckoutTheme.tertiaryBackgroundColor = .redCheckoutTheme.color = .whiteCheckoutTheme.secondaryColor = .lightGrayCheckoutTheme.errorColor = .blueCheckoutTheme.chevronColor = .whiteCheckoutTheme.font = UIFont(name: "Chalkboard SE", size: 12)!// Create the CheckoutAPIClient and CardViewController in the usual manner.let checkoutAPIClient = CheckoutAPIClient(publicKey: "<Your Public Key>",environment: .sandbox)let cardViewController = CardViewController(checkoutApiClient: checkoutAPIClient,cardHolderNameState: .normal,billingDetailsState: .normal)
CheckoutTheme class methods
Method | Description | Declaration |
---|---|---|
| Change the background color of the views. | `public static var primaryBackgroundColor: UI Color |
| Change the background color of input views. |
|
| Change the color of the |
|
| Change the main text color. |
|
| Change the input view placeholder text color. |
|
| Change the color of any error text |
|
| Change the font for all text content. |
|
| Change the style of the search bar. |
|
Customize the fields
Start by initializing the CardViewController
without the cardholder and billing details fields.
let cardViewController = CardViewController(checkoutApiClient: checkoutAPIClient,cardHolderNameState: .hidden,billingDetailsState: .hidden)
Access the cardViewController
card view to begin making edits to the colour and style.
func customizeTheme()func customizeTheme() {let cardView = cardViewController.cardViewcardView.backgroundColor = .systemBackgroundcardView.acceptedCardLabel.textColor = .labellet views: [StandardInputView] = [cardView.cardNumberInputView,cardView.expirationDateInputView,cardView.cvvInputView]views.forEach { view inview.layer.borderColor = UIColor.opaqueSeparator.cgColorview.layer.borderWidth = 2view.layer.cornerRadius = 10view.backgroundColor = .secondarySystemBackgroundview.textField.textColor = .labelview.label.textColor = .label}}
Inside the viewDidLoad
method, we can call the customizeFields function.
override func viewDidLoad() {super.viewDidLoad()customizeTheme()}