-2

I am very new to coding and I have been watching a numerous youtube videos on how to customize (adding my own image) to the bar button item on a toolbar and none of the ways seem to be working.

Could someone please help or point me to the right direction?

Or should I just create a button instead and add the image and "command" to that?

Thank you!

Screenshot of the problem

rmaddy
  • 314,917
  • 42
  • 532
  • 579
AP.fix
  • 37
  • 1
  • 7
  • Can you be more specific on what you want? Are you trying to link up a bar button item to do something, or having trouble arranging/moving them around? – George Jul 30 '18 at 22:38
  • lWhat do you mean by *customize*? Please be more specific. – TheLukeGuy Jul 30 '18 at 22:42
  • What I meant by customizing is to add/replace the bar button items with my own images on the toolbar. – AP.fix Jul 30 '18 at 22:54

1 Answers1

0

How to add an image to a UIBarButtonItem:

// Create toolbar
let toolbar = UIToolbar()
toolbar.sizeToFit()

// My button with an image
let button = UIBarButtonItem(image: UIImage(named: "myImageName"), style: .done, target: self, action: nil) // Add a selector if you want an action when it is clicked

// Create toolbar using items
toolbar.items = [button]
George
  • 25,988
  • 10
  • 79
  • 133