In iOS 15, UIKit has extended the usage of the scrollEdgeAppearance
, which by default produces a transparent background, to all navigation bars. The background is controlled by when your scroll view scrolls content behind the navigation bar. Your screenshots indicate that you are scrolled to the top, and so the navigation bar has selected its scrollEdgeAppearance
over the standardAppearance
that it would use when scrolled, and on previous versions of iOS.
Below is the complete code for changing navigation bar appearance is iOS 15.This code also can be used in SwiftUI app.
Enjoy and Learn 🙂
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = appThemeColor
appearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white,NSAttributedString.Key.font: UIFont.systemFont(ofSize: 22, weight: .bold)]
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().shadowImage = UIImage()