Nie*_*orn 27
在视图的初始化程序中,您可以设置导航栏的外观。在那里你必须将.shadowColor属性设置为.clear.
init() {
let appearance = UINavigationBarAppearance()
appearance.shadowColor = .clear
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
}
Run Code Online (Sandbox Code Playgroud)
我也遇到过这个问题。这是几乎相似的 帖子
但大部分答案都有副作用。对我来说,最好的解决方案是这个
UINavigationBar.appearance().barTintColor = .clear
UINavigationBar.appearance().backgroundColor = .clear
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
UINavigationBar.appearance().shadowImage = UIImage()
Run Code Online (Sandbox Code Playgroud)
并且还希望将 UIImage() 不是 'nil' 设置为 shadowImage 和 bacgroundImage 很重要。我使导航 displayMode 内联
.navigationBarTitle(Text(""), displayMode: .inline)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4374 次 |
| 最近记录: |