为什么我无法在导航栏中动态查看图片?
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 40, height: 20))
imageView.contentMode = .scaleAspectFill
imageView.sd_setImage(with: URL(string: currentFirma?.goruntuUrl ?? "")) { image, _, _, _ in
self.navigationController?.navigationBar.topItem?.titleView = UIImageView(image: image)
}
}
1条答案
按热度按时间h4cxqtbf1#
确保viewController嵌入在navigationController中,并编写如下代码