Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DisappearPing/ea6f08cdf346db2c78bb9f79be87a78d to your computer and use it in GitHub Desktop.
Save DisappearPing/ea6f08cdf346db2c78bb9f79be87a78d to your computer and use it in GitHub Desktop.
simple function for customNavigationTitleView with imageview
func setupCustomTitleViewAndCleanTitle(toTheNavigationItem theNavigationItem: UINavigationItem){
let titleView = UIView(frame: CGRect(x: 0, y: 0, width: 128, height: 44))
//Customizing Navigation Bar
// 3
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 128, height: 44))
imageView.contentMode = .ScaleAspectFit
// 4
let image = UIImage(named: "nav_logo")
imageView.image = image
// 5
titleView.addSubview(imageView)
theNavigationItem.titleView = titleView
theNavigationItem.title = ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment