我有麻烦了。我想在导航栏标题中使用图像,但出现错误,即“UIImage”不是“NSString”的子类型。下面的代码,看吧。
class Dashboard: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = UIImage(named: "logo.png")
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
有人可以推荐吗?谢谢!
最佳答案
设置navigationItem的titleView
var image = UIImage(named: "logo.png")
self.navigationItem.titleView = UIImageView(image: image)
关于ios - 我如何在 swift ios 的导航栏标题中使用图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26690904/