ios自定義凸起TabBar

2022-09-06 16:57:08 字數 702 閱讀 1966

demo在本文最後,先來說下在做自定義tabbar時候遇到的問題

1.tabbar設定的背景色與想要的效果不一致,有的專案可能需要解決tabbar上方描邊黑線

2.在poptoroot或者切換tabbar selectindex時候,原生的uitabbaritem會覆蓋在自定義的tabbar上的問題

3.凸起部分點選無響應問題

下面依次解決這幾個問題

問題1設定tabbar背景色後發現如下圖左側,實際想要效果如下圖右側

問題2將系統原生的uitabbaritem去掉,重寫下面幾個方法

- (nsarray*)items 

- (void)setitems:(nsarray*)items

- (void)setitems:(nsarray*)items animated:(bool)animated

問題3解決凸起無響應問題重寫如下方法

- (uiview *)hittest:(cgpoint)point withevent:(uievent *)event

else

}else

}

demo

本文參考資料

如有問題可以聯絡qq1120051590,一起交流學習

iOS 輕鬆實現自定義TabBar

自定義tabbar的案例網上不少,昨天受到開發小夥伴的影響,嘗試了一下非大神的取巧思路 demo 1 建立rootviewcontroller,後面建立幾個繼承的vc,將這幾個vc新增到tabbarcontroller中 2 新增window.rootvc uitabbarc 3 在rootview...

ios 完美封裝 tabBar 自定義加號按鈕

1.自定義繼承於uitabbarcontroller 2.利用kvc 替換系統的tabbar self setvalue lctabbar alloc init forkeypath tabbar nsmutabledictionary normalattrs nsmutabledictionary...

小程式自定義TabBar

tabbar requiredbackgroundmodes audio location debug true,sitemaplocation sitemap.json 查資料發現,tabbar的list下的第一項的路徑必須對應於pages配置下的第乙個頁面。因此,將tabbar中list的第乙個...