Adding UIBarButtonSystemItem icons to Nav-Toolbar (SWIFT)

I have been trying to find a way to add the UIBarButtonSystemItem icon to the toolbar. I have implemented it on my NavBar with the following code:

self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Action, target: self, action: "shareMeme")

But when it comes to the toolbar, I am at a loss. Any ideas?

Upvotes: 1

Views: 736

Answers (1)

Kristijan Delivuk
Kristijan Delivuk

Reputation: 1252

Try:

var items: Array<UIBarButtonItem> = []

items.append(UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Action, target: self, action: "selector"))

self.setToolbarItems(items as [AnyObject], animated: true)
self.navigationController?.setToolbarHidden(false, animated: true)

Upvotes: 1

Related Questions