Skip to content

Instantly share code, notes, and snippets.

@5oya
Last active October 21, 2017 06:19
Show Gist options
  • Save 5oya/7c199a972148c0e5dcee54e4725cc684 to your computer and use it in GitHub Desktop.
Save 5oya/7c199a972148c0e5dcee54e4725cc684 to your computer and use it in GitHub Desktop.
【iOS】UINavigationBarにカスタムの画像ボタンを追加する
extension UIButton {
static func createBarButton(imageString: String) -> UIButton {
let button = UIButton()
let buttonImage = UIImage(named: imageString)?.withRenderingMode(.alwaysOriginal)
button.setImage(buttonImage, for: .normal)
button.sizeToFit()
return button
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment