Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove image of UIBarButtonItem programmatically

I have a UIBarButtonItem with an image I setup in the storyboard. Later on in the program, I want to change the barButtonItem to have text, and not an image. Here's the code:

self.menuBarButton.setBackgroundImage(nil, forState: .Normal, barMetrics: .Default)
self.menuBarButton.title = "Some Text"

When I run the app, the barButton shows the image, and 3 dots. "...". What can I do to remove the image, and have text instead?

like image 552
Jessica Avatar asked Oct 18 '25 10:10

Jessica


1 Answers

Just set the .image-Property nil:

self.menuBarButton.image = nil;
like image 53
Kevin Griesbach Avatar answered Oct 21 '25 01:10

Kevin Griesbach