SwiftUI 設置狀態(tài)欄、導航欄背景顏色

在使用List等基于tableview滾動界面的控件的時候,就會使得整個界面的顏色變成灰蒙蒙的,看了看頁面結構,發(fā)現狀態(tài)欄跟導航欄的顏色是透明色,因此顯示出了后邊tableview滾動默認的背景色。
因此為了解決使用List,From等控件是導致的導航欄顏色不太好看的問題,需要設置一下其背景色。
相應代碼如下:

init() {
    // 設置狀態(tài)欄顏色
    let tabbarAppearance = UITabBarAppearance()
    tabbarAppearance.configureWithOpaqueBackground()
    tabbarAppearance.backgroundColor = .white
    UITabBar.appearance().standardAppearance = tabbarAppearance
    
    // 設置導航欄顏色
    let navibarAppearance = UINavigationBarAppearance()
    navibarAppearance.configureWithOpaqueBackground()
    navibarAppearance.backgroundColor = .white
    UINavigationBar.appearance().standardAppearance = navibarAppearance
    UINavigationBar.appearance().scrollEdgeAppearance = navibarAppearance
}
IMG_3A55B68B9261-1.jpeg
?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容