Ios 更新到Xcode 9后导航栏按钮中的图像未呈现

Ios 更新到Xcode 9后导航栏按钮中的图像未呈现,ios,swift,xcode,uinavigationbar,xcode9,Ios,Swift,Xcode,Uinavigationbar,Xcode9,我在UIViewController导航栏的右侧有两个UIButton,UIButton有图像。该应用程序在Xcode 8中运行之前一直运行良好,但当我更新Xcode 9时,它并没有渲染,而是占用了整个导航栏。 在Xcode 8中,它是 但是在升级到Xcode 9之后,它看起来是这样的 我设置导航栏的代码是 func setUpNavBar(){ self.navigationController?.navigationBar.isTranslucent = false

我在UIViewController导航栏的右侧有两个UIButton,UIButton有图像。该应用程序在Xcode 8中运行之前一直运行良好,但当我更新Xcode 9时,它并没有渲染,而是占用了整个导航栏。 在Xcode 8中,它是

但是在升级到Xcode 9之后,它看起来是这样的

我设置导航栏的代码是

  func setUpNavBar(){
    self.navigationController?.navigationBar.isTranslucent = false
    self.navigationItem.setHidesBackButton(true, animated: true)


    let notificationBtn = UIButton(type: .custom)
    notificationBtn.setImage(UIImage(named: "notificationIcon"), for: .normal)
    notificationBtn.frame = CGRect(x: 0, y: 0, width: 35, height: 35)
    notificationBtn.addTarget(self, action: #selector(HomeViewController.notificationClicked), for: .touchUpInside)
    let item1 = UIBarButtonItem(customView: notificationBtn)

    let profileBtn = UIButton(type: .custom)
    profileBtn.setImage(UIImage(named: "user_profile"), for: .normal)
    profileBtn.frame = CGRect(x: 0, y: 0, width: 35, height: 35)
     profileBtn.addTarget(self, action: #selector(HomeViewController.ProfileClicked), for: .touchUpInside)
    let item2 = UIBarButtonItem(customView: profileBtn)
    self.navigationItem.setRightBarButtonItems([item1,item2], animated: true)

}

我很困惑为什么会这样

ios11
中,您需要添加/设置高度限制,并使用
ui按钮

对于通知BTN

let widthConstraint = notificationBtn.widthAnchor.constraint(equalToConstant: 35)
let heightConstraint = notificationBtn.heightAnchor.constraint(equalToConstant: 35)
heightConstraint.isActive = true
widthConstraint.isActive = true

同样适用于profileBtn

iOS 11
中,您需要添加/设置高度限制,并使用
ui按钮

对于通知BTN

let widthConstraint = notificationBtn.widthAnchor.constraint(equalToConstant: 35)
let heightConstraint = notificationBtn.heightAnchor.constraint(equalToConstant: 35)
heightConstraint.isActive = true
widthConstraint.isActive = true

我想你应该标记为重复的lolIt工作感谢mani我想你应该标记为重复的lolIt工作感谢mani