我设置一个正常的图像视图作为我的导航栏项目自定义视图,但是这是它的发生:导航栏自定义图像视图问题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