Last active
November 12, 2016 11:46
-
-
Save genedelisa/6ee355440c2b5bc2aa28c86e978b5748 to your computer and use it in GitHub Desktop.
Create buttons in a navigationController's UIToolbar using Swift 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if let nav = navigationController { | |
nav.setToolbarHidden(false, animated: false) | |
// doesn't really set the button's tint | |
UIToolbar.appearance().tintColor = UIColor.black | |
// instead of setting the text color of each bar button | |
UIBarButtonItem.appearance().tintColor = UIColor.black | |
//http://www.fileformat.info/info/unicode/char/26ed/index.htm | |
let settingsButton = UIBarButtonItem(title: "\u{2699}", | |
style: .plain, | |
target: self, | |
action: #selector(TracksViewController.settings)) | |
let peace = UIBarButtonItem(title: "\u{262E}", | |
style: .plain, | |
target: self, | |
action: #selector(TracksViewController.settings)) | |
// from the musical symbol block, not the misc symbol block | |
let eighth = UIBarButtonItem(title: "\u{1D160}", | |
style: .plain, | |
target: self, | |
action: #selector(TracksViewController.settings)) | |
toolbarItems = [settingsButton, peace, eighth] | |
// or | |
self.navigationItem.setRightBarButtonItems([settingsButton, peace, eighth], animated: true) | |
self.navigationItem.setLeftBarButtonItems([settingsButton, peace, eighth], animated: true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment