简体   繁体   中英

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM