Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation bar is transparent when scrolling starts in iOS15 only

I've been searching different solutions and the one that I keep seeing repeatedly is to set the scroll edge appearance equal to the standard appearance. I have also looked at this solution. Neither solution is working for me. I am also not seeing that this issue appears once the user gets to the end of the scrollable content, which is what I believe scroll edge is. I am seeing the problem happen as soon as the user starts scrolling in a long list. I've included photos below, with confidential data blurred out. The only place in my app where the navigation bar looks correct is in the master view. My app architecture is master detail. It worked perfect in all navigation bars in iOS 14, this issue is specific to iOS 15.

Scenario 1: Master View Controller List View (nav bar looks correct once scrolling starts)

Master list view very top Master list view scrolling

Scenario 2: After selecting an item on the MVC table (nav bar is transparent and not blurred once scrolling starts)

List view very top List view scrolling

Here is my current view in storyboard with the default values for standard and scroll edge. storyboard view

Some things I have tried besides setting scroll edge appearance equal to standard:

  1. Unchecking transparent in Scroll Edge Appearances
  2. Changing the blur style (in both standard and scroll edge)
  3. Setting a background color

like image 823
Kate M Avatar asked Oct 26 '22 11:10

Kate M


1 Answers

In iOS 15, UIKit has extended the usage of the scrollEdgeAppearance, which by default produces a transparent background, to all navigation bars. Set scrollEdgeAppearance as below code. It is working for me.

if #available(iOS 15, *) {
        let appearance = UINavigationBarAppearance()
        appearance.configureWithOpaqueBackground()
        appearance.backgroundColor = < your tint color >
        navigationController?.navigationBar.standardAppearance = appearance;
        navigationController?.navigationBar.scrollEdgeAppearance = navigationController?.navigationBar.standardAppearance
    } 
like image 97
sufian Avatar answered Nov 17 '22 14:11

sufian