【发布时间】:2017-10-12 07:06:04
【问题描述】:
我在 UIViewController 的导航栏右侧有两个 UIButton,UIbuttons 有图像。该应用程序运行良好,直到它在 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)
}
我很困惑为什么会这样。
【问题讨论】:
标签: ios swift xcode uinavigationbar xcode9