How to set backButton text to empty?

2019-07-05 13:42发布

I tried this code:

navigationController?.navigationItem.backBarButtonItem?.title = ""

but it does not work and did not change anything. How can I set backButton text to empty?

6条回答
聊天终结者
2楼-- · 2019-07-05 14:18
self.navigationController!.navigationBar.topItem!.title = ""
查看更多
Luminary・发光体
3楼-- · 2019-07-05 14:23

I tried this code for back button title. and it's work correctly

 let barButton = UIBarButtonItem()
 barButton.title = ""
 self.navigationController?.navigationBar.topItem?.backBarButtonItem = barButton
查看更多
走好不送
4楼-- · 2019-07-05 14:23

You have to change the previous controller's title, try doing so before the segue in the viewDidDisappear

查看更多
别忘想泡老子
5楼-- · 2019-07-05 14:32

You should use:

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

for see just < instead of < viewController

查看更多
别忘想泡老子
6楼-- · 2019-07-05 14:38

To remove the backButtonItem's title, place this line of code in the viewDidLoad: of the View Controller that the backButtonItem is in:

navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, 
target: nil, action: nil)
查看更多
男人必须洒脱
7楼-- · 2019-07-05 14:39
self.navigationItem.leftBarButtonItem=nil;

or

self.navigationItem.backBarButtonItem=nil;
查看更多
登录 后发表回答