4

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?

Jessica
  • 9,379
  • 14
  • 65
  • 136
  • Maybe try to create an image of clearColor using [this](http://stackoverflow.com/questions/26542035/create-uiimage-with-solid-color-in-swift#answer-26542235) function? – mkz Sep 13 '15 at 22:48

1 Answers1

5

Just set the .image-Property nil:

self.menuBarButton.image = nil;
Kevin Griesbach
  • 668
  • 7
  • 19