有没有办法改变条纹取消按钮的标题?
我需要将其更改为“ Back”,实际上,“ Back”是一个更好的词来描述其行为。
我正在以这种方式介绍控制器:
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)
答案 0 :(得分:1)
在条带文件中转到STPCoreViewController.m。
只需替换此方法
- (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;
}
}
使用
- (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;
}
}
答案 1 :(得分: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)
}