我正试图从 UINavigationBar
同时使其完全白色,使其与背景融为一体。
下面是我的代码。
nav.navigationBar.standardAppearance.shadowColor = UIColor.white //also tried UIColor.clear
nav.navigationBar.barTintColor = UIColor.white
nav.navigationBar.backgroundColor = UIColor.white
nav.navigationBar.barStyle = .default
nav.navigationBar.isTranslucent = false
最终结果如下图所示。正如你所看到的,我的导航栏不是完全白色的。
如果我去掉我在导航栏上设置的 shadowColor
我确实得到了一个白色的背景,但在底部有一条线。
如果有人能帮助我得到我想要的结果,我会很感激。
看看这段代码。
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = .white
appearance.shadowColor = .none
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
UINavigationBar.appearance().tintColor = .black
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance