Search code examples
iosswiftxcodeuinavigationcontrollertitlebar

Swift, is it possible to use SF Symbols in Navigation Bar title?


Wondering how I can use SF Symbols as View Controller title. Is it possible to do so?

    viewController.title = [somehow want to use an SF Symbol here]

Solution

  • Yes you can do that using imageView and SFSymbol

    let imageView = UIImageView(image: UIImage(systemName: "gear"))
            imageView.contentMode = .scaleAspectFit
            imageView.clipsToBounds = true
            navigationItem.titleView = imageView