最近想記錄一下想到的一些雖然毫無(wú)技術(shù)含量但也值得注意的地方,想到了就會(huì)記錄下來(lái)
想到一個(gè)常用的,就是二級(jí)頁(yè)面一般都回去隱藏底部UITabBar,可能有的小伙伴都是在需要的當(dāng)前頁(yè)面push的時(shí)候去實(shí)現(xiàn)的,例如:
vc.hidesBottomBarWhenPushed = true;
這樣當(dāng)然是沒(méi)問(wèn)題,只是需要每次都寫(xiě)一次,雖然也不算麻煩,這里有個(gè)小技巧,就是在自己的UINavigationController里重寫(xiě)pushViewController方法,通過(guò)判斷子控制器的數(shù)量去實(shí)現(xiàn)是否隱藏
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
if children.count > 0 {
viewController.hidesBottomBarWhenPushed = true
}
super.pushViewController(viewController, animated: true)
}