0
我在UIViewController的導航欄的右側有兩個UIButton,UIbuttons有圖像。該應用程序工作正常,直到它在Xcode 8中運行,但是當我更新Xcode 9時,它不是呈現,而是整個導航欄。 在Xcode中8是 更新到Xcode 9後導航欄按鈕中沒有渲染圖像
但更新到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)
}
我很困惑它爲什麼會發生。
我認爲你應該標記爲重複大聲笑 –
它的作品感謝人 – Prathamesh