I've read this article: Change the text of a UILabel (UIBarButtonItem) on a toolbar programmatically
But it seems not working for my auto-hide toolbar?
I also tried barbuttonItem.title
to set the text, failed too.
Any idea?
Select the UIBarButtonItem in Interface Builder , open the inspector (Command + Shift + I) , and select "Custom" under the dropdown next to Identifier .
In case you want to initialize UIBarButtonItem programmatically in Swift 4+ should be done as following: editButton = UIBarButtonItem(title: "Edit", style: . plain, target: self, action: #selector(editAct)).
Are you creating the button in Interface Builder
? Make sure that the identifier is set to Custom, otherwise you will not be able to change the title.
Select the UIBarButtonItem
in Interface Builder
, open the inspector (Command + Shift + I)
, and select "Custom" under the dropdown next to Identifier
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With