私は私のナビゲーションバーの項目のカスタムビューとして通常の画像表示を設定していますが、これはそれが何が起こっているかである:これはナビゲーションバーのカスタム画像表示問題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のの制約を追加することはできません賢明
その他、それはあなたの代わりにフレーム – iPatel
感謝の自動レイアウトを使用する必要がありiOSの11の問題だ@iPatel 。画像ビューをナビゲーションバーに制約するか、高さと幅を設定するだけですか? – Cesare
これは@iPatelを動作させます。返信として投稿することを自由に感じてください – Cesare