使用自定义uinavigationbar初始化uinavigationcontroller时,我很难找到一种方法来删除“鬼”后退按钮(除了蓝色后退箭头之外)。当我单击该后退按钮时,我会看到我的自定义导航栏,但我不想不必单击该后退按钮。
我已经尝试了几乎所有其他解决方案,包括setHidesBackButton等,并按照我调用这些函数的顺序进行操作。
class TabsVC : UITabBarController {
func setupTabBar() {
// setup feed tab
let navVC = UINavigationController(navigationBarClass: NavBar.self, toolbarClass: nil)
self.navigationItem.setHidesBackButton(true, animated: false)
let feedVC = FeedVC()
navVC.pushViewController(feedVC, animated: false)
let feedIcon = UIImage.fontAwesomeIcon(name: .home, textColor: ColorConstants.baseColor, size: CGSize(width: 40, height: 40))
navVC.tabBarItem = UITabBarItem(title: "", image: feedIcon, tag: 1)
// other tabs stuff
}
class NavBar : UINavigationBar {
func prepare() {
let item = UINavigationItem(title: "")
let titleV = titleView()
item.titleView = titleV
item.hidesBackButton = true
item.setHidesBackButton(false, animated: false)
item.leftBarButtonItem = UIBarButtonItem(image: UIImage.fontAwesomeIcon(name: .userCircle, textColor: ColorConstants.baseColor, size: CGSize(width: 40, height: 40)), style: .plain, target: nil, action: nil)
item.leftBarButtonItem?.tintColor = .white
item.leftBarButtonItem?.action = #selector(moveToProfileScreen)
self.pushItem(item, animated: false)
}
我只希望能够从头开始查看我的自定义导航栏,而不必单击空白的后退按钮来查看导航栏。谢谢!