iosswiftswiftui

SwiftUI Remove NavigationBar Bottom Border


When using SwiftUI how do you remove the bottom 1px border of a navigation bar?

iOS SwiftUI NavigationBar Example


Solution

  • In the initializer of your View you can set the appearance of your navigation bar. There you have to set the .shadowColor property to .clear.

    init() {
        let appearance = UINavigationBarAppearance()
        appearance.shadowColor = .clear
        UINavigationBar.appearance().standardAppearance = appearance
        UINavigationBar.appearance().scrollEdgeAppearance = appearance
    }