将UIBarButtonSystemItem图标添加到Nav-Toolbar(SWIFT)

时间:2015-08-27 17:45:19

标签: swift uinavigationbar uinavigationitem uibarbuttonsystemitem

我一直在尝试找到一种将UIBarButtonSystemItem图标添加到工具栏的方法。我已经使用以下代码在我的NavBar上实现了它:

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

但是当谈到工具栏时,我感到很茫然。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

尝试:

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)