在使用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