I am trying to place an image logo as a title within the navigation bar of an iOS app using Swift. I included the image in the assets folder (Images.xcassets). I looked into this question but no luck.
The following is my code:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let logo = UIImage(named: "logo") as UIImage
let imageView = UIImageView(image:logo)
imageView.frame.size.width = 200;
imageView.frame.size.height = 45;
self.navigationItem.titleView = imageView
}
...
}