1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import Foundation
- class NCMainNavigationController: UINavigationController {
-
- private let appDelegate = UIApplication.shared.delegate as! AppDelegate
- required init?(coder: NSCoder) {
- super.init(coder: coder)
-
- NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: NCGlobal.shared.notificationCenterChangeTheming), object: nil)
-
- changeTheming()
- }
- @objc func changeTheming() {
-
- if #available(iOS 13.0, *) {
-
- let appearance = UINavigationBarAppearance()
-
- appearance.configureWithOpaqueBackground()
- appearance.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.shared.label]
- appearance.backgroundColor = NCBrandColor.shared.systemBackground
- appearance.configureWithOpaqueBackground()
- appearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor : NCBrandColor.shared.label]
- appearance.backgroundColor = NCBrandColor.shared.systemBackground
- navigationBar.scrollEdgeAppearance = appearance
- navigationBar.standardAppearance = appearance
-
- } else {
-
- navigationBar.barStyle = .default
- navigationBar.barTintColor = NCBrandColor.shared.systemBackground
- navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:NCBrandColor.shared.label]
- navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor:NCBrandColor.shared.label]
- }
-
- navigationBar.tintColor = .systemBlue
- navigationBar.setNeedsLayout()
- }
- }
|