Skip to content

Navigation Bar Appearance Lost When Using SwiftUI with UIKit + Introspect #450

Open
@Mickael-tinytap

Description

@Mickael-tinytap

Description

Hi,

I’m using a mixed UIKit and SwiftUI setup in my app. Specifically, I have a UIViewController embedded in a UINavigationController with a custom UINavigationBarAppearance.

Inside this controller, I’m embedding a SwiftUI view using UIHostingController. When I add an Introspect modifier (for example, to access the underlying UIScrollView), the navigation bar unexpectedly loses its configured appearance and becomes transparent.

I noticed there was a related issue marked as resolved, which suggested this behavior should no longer occur—but I’m still seeing the problem in the latest version.

It's happen only for nav configured as scrollEdgeAppearance.configureWithTransparentBackground(), if I set it as opaque it's still work.

Here the style of my navigationBarController

        let appearance = UINavigationBarAppearance()
        let scrollEdgeAppearance = UINavigationBarAppearance()
        
        appearance.configureWithDefaultBackground()
        appearance.backgroundEffect = UIBlurEffect(style: .systemMaterial)
        appearance.backgroundColor = .clear
        
        scrollEdgeAppearance.configureWithTransparentBackground()
        scrollEdgeAppearance.backgroundColor = .clear
        
        navigationBar.standardAppearance = appearance
        navigationBar.scrollEdgeAppearance = scrollEdgeAppearance
        navigationBar.compactAppearance = appearance
        navigationBar.compactScrollEdgeAppearance = appearance
        
        navigationBar.isTranslucent = true

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions