gpt4 book ai didi

ios - 在 iOS 13 上隐藏后退按钮标题

转载 作者:行者123 更新时间:2023-11-29 05:29:57 24 4
gpt4 key购买 nike

我们的应用程序的部署目标是 iOS 10。我们使用以下代码隐藏所有后退按钮标题(对于整个应用程序)

let attributes: [NSAttributedString.Key : Any] = [
.font : UIFont.systemFont(ofSize: 0.001),
.foregroundColor: UIColor.clear
]

let barButtonItemAppearance = UIBarButtonItem.appearance(whenContainedInInstancesOf: [UINavigationBar.self])
barButtonItemAppearance.setTitleTextAttributes(attributes, for: .normal)
barButtonItemAppearance.setTitleTextAttributes(attributes, for: .highlighted)

这种情况一直持续到 iOS 13,后退按钮标题不再隐藏。

我看过有关新外观 API 的 WWDC 2019 视频,但据我所知,它只告诉我如何将新 API 用于单个导航栏(而不是整个应用程序)。

我怎样才能实现这个目标?

最佳答案

添加到父级(堆栈中的前一个) Controller 的 viewDidLoad() 方法中。

self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.plain, target:nil, action:nil)

在下一个屏幕中,将仅显示箭头图像。

或者您可以将此代码放在pushViewController方法之前,例如

func presentNextScreen(_ controller: UIViewController){
// Suppress title in the back button on the next screen.
self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.plain, target:nil, action:nil)
self.navigationController?.pushViewController(controller, animated: true)
}

关于ios - 在 iOS 13 上隐藏后退按钮标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57709516/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com