iOS13 去掉 UITabbar 黑線

iOS 13 之前, 去掉黑線:設置UITarBar的 backgroundImage 和 shadowImage即可:

? ? ? ? tabbar.backgroundImage = UIImage(color: UIColor.clear)

? ? ? ? tabbar.shadowImage = UIImage(color: UIColor.clear)


iOS13之后不好使了,改用下面的方法:

? ? ? ? let appearance = tabbar.standardAppearance.copy()

? ? ? ? appearance.backgroundImage = UIImage(color: UIColor.clear)

? ? ? ? appearance.shadowImage = UIImage(color: UIColor.clear)

? ? ? ? tabbar.standardAppearance = appearance

1


所以兼容代碼如下:

? ? if #available(iOS 13, *) {

? ? ? ? let appearance = tabbar.standardAppearance.copy()

? ? ? ? appearance.backgroundImage = UIImage(color: UIColor.clear)

? ? ? ? appearance.shadowImage = UIImage(color: UIColor.clear)

? ? ? ? tabbar.standardAppearance = appearance

? ? } else {

? ? ? ? tabbar.backgroundImage = UIImage(color: UIColor.clear)

? ? ? ? tabbar.shadowImage = UIImage(color: UIColor.clear)

? ? }


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、簡介 <<UITabBar類實現(xiàn)了一個選擇兩個或多個按鈕的控制,并稱之為項目。一個標簽欄最常見的用途是實現(xiàn)一個...
    無邪8閱讀 7,626評論 0 4
  • 一、UITabBarController以其相關(guān)控件之間的關(guān)系 @interface UITabBarContro...
    西門淋雨閱讀 3,300評論 0 1
  • 1.1 UINavigationController 導航欄控制器基本是項目必備啊,所以我們UI大姐們也是想著花樣...
    MissLu16閱讀 484評論 0 2
  • IOS常用代碼總結(jié) 1、設置UILabel行間距 NSMutableAttributedString* attrS...
    難卻卻閱讀 647評論 0 0
  • 1.Activity定義 1.從表面上看,Activiy是OPhone應用程序的一個圖形用戶界面 2.對于開發(fā)者而...
    簏人閱讀 398評論 0 0

友情鏈接更多精彩內(nèi)容