我有一个UIViewController
,我从互联网上加载图片,我想将其显示为导航标题。
这是我从互联网上取完图片后的代码
代码段:
let imgView = UIImageView(frame: CGRect(x: 0, y: 0, width: 40, height: 40))
imgView.backgroundColor = UIColor(red: 0.5, green: 0.5, blue: 0, alpha: 0.3)
imgView.image = result.image! //Contains the picture from internet
imgView.contentMode = .ScaleAspectFit
self.navigationItem.titleView = imgView
结果如下: