如何自定义导航后退符号和导航后退文本? [英] How to customize the navigation back symbol and navigation back text?
问题描述
现在是后面的图标和后面的文字:
但如果我想要我的导航回来:
我试图将背面设置为我想要的图标图像:
但它没用。
您可以通过多种方式隐藏按钮文本。尝试这种简单方法。
第1步:转到 mainstoryBoard
并点击 navigationBar
。
第2步: 转到属性检查器
导航项目
在<$中添加 BLANK SPACE c $ c>后退按钮
第3步: 如果要更改 backButton
文本方法几乎相同。
更新1:如果您想将图像用作后退按钮,请检查
输出
This is the back icon and back text now:
But if I want my navigation back like this:
I have tried to set the back to my want icon image:
But it useless.
You can hide back button text in many ways.Try this simple approach.
Step1: Goto your mainstoryBoard
and click navigationBar
.
Step 2: Goto Attributes Inspector
under Navigation Item
add a BLANK SPACE in Back Button
Step 3: If you want to change backButton
text method is pretty much the same.
Update 1: If you want to use an image as a back button check this link
Update 2:
Method 2: Using custom image as a back button.
Paste below code into your detailVC
and set image for your back Button.
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)
}
I am setting back button image in assets catalogue
with the 32
pixel size.I am not sure about the asset image size.Check with apple doc
about the size class.
Output:
这篇关于如何自定义导航后退符号和导航后退文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!