Skip to content

Instantly share code, notes, and snippets.

@oalansari82
Last active May 25, 2018 13:06
Show Gist options
  • Save oalansari82/663df38b06b4d244f667e45e314a3102 to your computer and use it in GitHub Desktop.
Save oalansari82/663df38b06b4d244f667e45e314a3102 to your computer and use it in GitHub Desktop.
Replace NavigationController's title with a logo
// Here you can set View width and height as per your requirement for displaying supportView position in navigationbar
let supportView = UIView(frame: CGRect(x: 0, y: 0, width: 120, height: 40))
//supportView.backgroundColor = UIColor.red
let logo = UIImageView(image: UIImage(named: "logo")) //UIImage(named: "SelectAnAlbumTitleLettering")
// customize the origin as (45,5) but can pass them as your requirement.
logo.frame = CGRect(x: 0, y: -5, width: supportView.frame.size.width, height: supportView.frame.size.height)
supportView.addSubview(logo)
supportView.contentMode = .center
navigationItem.titleView = supportView
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment