0

I open a modal with below code. I am using .fullScreen because I need viewWillAppear called after this controller is dismissed.

let controller = self.storyboard!.instantiateViewController(withIdentifier: "Login")
controller.modalPresentationStyle = .fullScreen
self.present(controller, animated: true, completion: nil)

When the controller is presented:

top

My problem is, how can I change the top color to keep the same as the navigation?

Haroldo Gondim
  • 7,725
  • 9
  • 43
  • 62

1 Answers1

2

For iOS 13 you can use UINavigationBarAppearance, as seen on the docs and on this answer here.

if #available(iOS 13.0, *) {
    let navBarAppearance = UINavigationBarAppearance()
    navBarAppearance.configureWithOpaqueBackground()
    navBarAppearance.titleTextAttributes = [.foregroundColor: UIColor.white]
    navBarAppearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
    navBarAppearance.backgroundColor = <insert your color here>
    navigationBar.standardAppearance = navBarAppearance
    navigationBar.scrollEdgeAppearance = navBarAppearance
}
Marina Aguilar
  • 1,151
  • 9
  • 26