AppDelegate+Swift.swift 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // AppDelegate+Swift.swift
  3. // Nextcloud
  4. //
  5. // Created by Philippe Weidmann on 24.04.20.
  6. // Copyright © 2020 Marino Faggiana. All rights reserved.
  7. //
  8. import Foundation
  9. extension AppDelegate {
  10. @objc func configureNavBarForViewController(_ viewController: UIViewController) {
  11. if #available(iOS 13.0, *) {
  12. var navBarAppearance = UINavigationBarAppearance()
  13. navBarAppearance.configureWithOpaqueBackground()
  14. navBarAppearance.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  15. navBarAppearance.backgroundColor = NCBrandColor.sharedInstance.backgroundView
  16. navBarAppearance.shadowColor = .clear
  17. navBarAppearance.shadowImage = UIImage()
  18. viewController.navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
  19. navBarAppearance = UINavigationBarAppearance()
  20. navBarAppearance.configureWithOpaqueBackground()
  21. navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.sharedInstance.textView]
  22. navBarAppearance.backgroundColor = NCBrandColor.sharedInstance.tabBar
  23. viewController.navigationController?.navigationBar.standardAppearance = navBarAppearance
  24. } else {
  25. viewController.navigationController?.navigationBar.barStyle = .default
  26. viewController.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.backgroundView
  27. viewController.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:NCBrandColor.sharedInstance.textView]
  28. viewController.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor:NCBrandColor.sharedInstance.textView]
  29. }
  30. viewController.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brand
  31. viewController.navigationController?.navigationBar.setNeedsLayout()
  32. }
  33. }