2

Hello I am creating app with Swift i have just started creating app and take one View Controller and embed in navigation controller and for remove navigation bar border i used below code

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for:.default)            
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.layoutIfNeeded()

and for dealing with Dark Theme i have added one more line as below

i am adding Screen Shot Of Light Mode And Dark Mode for better explanation

overrideUserInterfaceStyle = .light

but when iphone is in darkmode Navigation Bar Style changed to light is there any solution to handle navigation bar style while dark mode is enabled

This dark mode Screen Shot

This Is Light Mode Screen Shot

Kindly tell me if anyone have any solution for this

gipeje
  • 61
  • 7

1 Answers1

0

Use UINavigationBarAppearance() to customize UINavigationBar in iOS13 (where dark mode feature appeared):

if #available(iOS 13.0, *) {
   let appearance = UINavigationBarAppearance()
   appearance.backgroundColor = UIColor.colorYouNeed
   self.navigationController?.navigationBar.standardAppearance = appearance
}
Alex Sh.
  • 579
  • 5
  • 17