gpt4 book ai didi

ios - 如何自定义导航后退符号和导航后退文字?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:11:32 25 4
gpt4 key购买 nike

现在是后退图标和后退文字:

但是如果我希望我的导航像这样返回:

我已经尝试将背面设置为我想要的图标图像:

但是没用。

最佳答案

您可以通过多种方式隐藏后退按钮文本。试试这个简单的方法。

第 1 步:转到您的 mainstoryBoard 并单击 navigationBar

第 2 步:转到 Navigation Item 下的 Attributes Inspector,在 Back Button 中添加一个 BLANK SPACE

enter image description here

第 3 步:如果您想更改 backButton 文本方法几乎​​相同。

enter image description here

更新 1:如果您想将图像用作后退按钮,请检查此 link


更新 2:

方法 2:使用自定义图像作为后退按钮。

将下面的代码粘贴到您的 detailVC 中并为您的后退按钮设置图像。

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

title = "Detail VC"

let customButton = UIBarButtonItem(image: UIImage(named: "back"), style: .plain, target: self, action: #selector(backButtonTapped)) //
self.navigationItem.leftBarButtonItem = customButton
}

func backButtonTapped() {
_ = navigationController?.popToRootViewController(animated: true)
}

我在 assets catalogue 中设置后退按钮图像,其大小为 32。我不确定 Assets 图像的大小。请查看 apple doc 关于尺寸等级。

enter image description here

输出:

enter image description here

关于ios - 如何自定义导航后退符号和导航后退文字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43546132/

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