Translucent (NOT transparent) background for UINavigationBar that makes content subtly visible behind it as you scroll

31 views Asked by At

I’ve had no luck setting my SwiftUI NavigationBar to be translucent, so that content scrolled is subtly visible behind it. The closest I’ve managed is making it transparent, which results in the scrolled content being completely visible, which is not what I’m after. For reference, I achieved this by dropping this in my struct’s init:

init() {
    UINavigationBar.appearance().setBackgroundImage(UIImage(), for: UIBarMetrics.default)
    UINavigationBar.appearance().shadowImage = UIImage()
    UINavigationBar.appearance().isTranslucent = true
    UINavigationBar.appearance().tintColor = .clear
    UINavigationBar.appearance().backgroundColor = .clear
}

Looks like below after I’ve scrolled a bit:

enter image description here

I’ve tried removing the background image, and although there seems to be an effect, the content is still not visible behind:

    UINavigationBar.appearance().isTranslucent = true
    UINavigationBar.appearance().tintColor = .clear
    UINavigationBar.appearance().backgroundColor = .red

enter image description here

When searching for a solution, everything I’ve found concerns making it transparent.

0

There are 0 answers