我設置一個正常的圖像視圖作爲我的導航欄項目自定義視圖,但是這是它的發生:導航欄自定義圖像視圖問題11
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 34, height: 34))
imageView.kf.setImage(with: user.profilePictureURL)
if user.profilePictureURL == nil {
imageView.image = #imageLiteral(resourceName: "ProfilePlaceholderSuit")
}
imageView.backgroundColor = .white
imageView.layer.masksToBounds = true
imageView.layer.cornerRadius = 17
imageView.layer.borderWidth = 1
imageView.layer.borderColor = UIColor.white.cgColor
imageView.isUserInteractionEnabled = true
imageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap)))
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: imageView)
print("ok, so the image view frame is", imageView.frame) // 0, 0, 34, 34
不,這不是與翠鳥框架問題補充ImageView的的限制,它的IOS 11的問題,您應該使用的,而不是框架 – iPatel
由於自動佈局@iPatel 。我是否必須將圖像視圖限制到導航欄或者只是設置其高度和寬度? – Cesare
這工作@iPatel。隨意張貼,作爲回答 – Cesare