There's a way to change the Stripe cancel button title?
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)
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;
}
}
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)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.