2

There's a way to change the Stripe cancel button title?

Stripe PaymentMethodsController

I need to change it to "Back", in fact, "Back" is a better word to describe its behavior.

I am presenting the controller of this way:

let customerContext = STPCustomerContext(keyProvider: StripeClient.shared)
let paymentMethodsViewController = STPPaymentMethodsViewController(configuration: STPPaymentConfiguration.shared(), theme: STPTheme.default(), customerContext: customerContext, delegate: self as STPPaymentMethodsViewControllerDelegate)
let navigationController = UINavigationController(rootViewController: paymentMethodsViewController)
present(navigationController, animated: true)
el_quick
  • 4,656
  • 11
  • 45
  • 53

2 Answers2

2

Go to STPCoreViewController.m in stripe files.

Just Replace this Method

- (void)commonInitWithTheme:(STPTheme *)theme {
_theme = theme;

if (![self useSystemBackButton]) {
    self.cancelItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
                                                                    target:self
                                                                    action:@selector(handleCancelTapped:)];

    self.stp_navigationItemProxy.leftBarButtonItem = self.cancelItem;
    }
}

With

- (void)commonInitWithTheme:(STPTheme *)theme {
_theme = theme;

if (![self useSystemBackButton]) {

    self.cancelItem = [[UIBarButtonItem alloc]
                                   initWithTitle:@"Back"
                                   style: UIBarButtonItemStylePlain
                                   target:self
                                   action:@selector(handleCancelTapped:)];

    self.stp_navigationItemProxy.leftBarButtonItem = self.cancelItem;
    }
}
Taimoor Suleman
  • 1,588
  • 14
  • 29
0
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
    // first
    let backItem = UIBarButtonItem()
    backItem.title = "Back"
    self.viewControllers.last?.navigationItem.backBarButtonItem = backItem
    // then
    super.pushViewController(viewController, animated: animated)

}