之前設(shè)計那邊需要一個tabbar中心突出的效果用的這個庫還不錯推薦下還帶幾種動畫動畫處理的還很細膩2700個星的庫還是很不錯的RAMAnimatedTabBarController地址地址請戳
之后遇到了一個問題就是隱藏tabbar圖標(biāo)不隱藏看了下圖發(fā)現(xiàn)作者吧tabbar弄到了windows上,而且看了issus貌似大家都遇到這個問題作者也沒回復(fù),自己弄吧。蛋疼了,又不想換庫折騰了幾天自己寫了個類。
importUIKit
extensionRAMAnimatedTabBarController:UINavigationControllerDelegate{
funchideTabBar(flag:Bool) {
letatc =self
leticons= atc.iconsView
if(flag ==true){
foriconinicons {
icon.icon.superview?.hidden=true
}
atc.tabBar.hidden=true
}else{
atc.tabBar.hidden=false
foriconinicons {
ifletsup = icon.icon.superview{
sup.hidden=false
sup.superview?.bringSubviewToFront(sup)
}
}
}
}
判斷下進來是push還是其余的我們這邊所有的子界面是隱藏的我直接做的是push進來進行隱藏
funcnavigationController(navigationController:UINavigationController, willShowViewController viewController:UIViewController, animated:Bool) {
hideTabBar(viewController.hidesBottomBarWhenPushed)
}
funcnavigationController(navigationController:UINavigationController, didShowViewController viewController:UIViewController, animated:Bool){
hideTabBar(viewController.hidesBottomBarWhenPushed)
}
}
然后再RAMAnimatedTabBarController.swift里面調(diào)用58行左右的didload里面添加
super.viewDidLoad()
letconls = (self.viewControllersas? [UIViewController])?.filter({$0isUINavigationController}) ?? []
forctlinconls{
(ctlas!UINavigationController).delegate=self
}
可以解決已經(jīng)提issus但是最近發(fā)現(xiàn)連續(xù)多級push在返回來tabbar會蓋住tabbar的image,我懷疑是tababr每次進界面時候應(yīng)該會走topviewcontroller之類的方法,但是在tabbar的.h里面也沒找到這個方法,解決這個問題在隱藏界面直接執(zhí)行這兩個方法讓脫離本界面時候進行顯示。這個必須手寫勾選store時候會造成出界面時候tabbar再次覆蓋image
-(void)viewWillAppear:(BOOL)animated
{
self.hidesBottomBarWhenPushed=YES;
}
-(void)viewWillDisappear:(BOOL)animated
{
self.hidesBottomBarWhenPushed=NO;
}