From 28b74008ead718b74fa1de2c8238f4a11d9ae61f Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 17 Oct 2021 19:31:13 +0200 Subject: [PATCH] iOS 15: Restore proper navigation bar appearance --- Passepartout/App/iOS/CHANGELOG.md | 1 + Passepartout/App/iOS/Global/Theme.swift | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Passepartout/App/iOS/CHANGELOG.md b/Passepartout/App/iOS/CHANGELOG.md index 91665c1a..a52c2cea 100644 --- a/Passepartout/App/iOS/CHANGELOG.md +++ b/Passepartout/App/iOS/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- iOS 15: Navigation bar has broken appearance. - Missing account guidance footer in some providers. - Files imported via Music (iTunes) File Sharing did not show up. diff --git a/Passepartout/App/iOS/Global/Theme.swift b/Passepartout/App/iOS/Global/Theme.swift index fdc7ec0a..c5e7fb62 100644 --- a/Passepartout/App/iOS/Global/Theme.swift +++ b/Passepartout/App/iOS/Global/Theme.swift @@ -88,10 +88,22 @@ struct Theme { extension Theme { func applyAppearance() { + if #available(iOS 15, *) { + let navBar = UINavigationBarAppearance() + navBar.configureWithOpaqueBackground() + navBar.backgroundColor = palette.primaryBackground + navBar.titleTextAttributes = [.foregroundColor: palette.primaryLightText] + navBar.buttonAppearance.normal.titleTextAttributes = navBar.titleTextAttributes + navBar.doneButtonAppearance.normal.titleTextAttributes = navBar.titleTextAttributes + let appearance = UINavigationBar.appearance() + appearance.standardAppearance = navBar + appearance.scrollEdgeAppearance = appearance.standardAppearance + } + let bar = UINavigationBar.appearance() bar.barTintColor = palette.primaryBackground bar.tintColor = palette.primaryLightText - bar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: palette.primaryLightText] + bar.titleTextAttributes = [.foregroundColor: palette.primaryLightText] bar.largeTitleTextAttributes = bar.titleTextAttributes let pickerBar = UINavigationBar.appearance(whenContainedInInstancesOf: [UIDocumentBrowserViewController.self])