0
我有一個UIViewController
我從網上加載圖片,我想顯示它作爲導航titleView。導航標題UIImageView不能居中
這裏是我的代碼時,我已經完成了從互聯網獲取的圖片
代碼段:
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
這裏是結果:
看到這個http://stackoverflow.com/questions/28121388/cant-set-titleview-in-the-center-of-navigation-bar-because-back-button –