Fix #36: iOS-17-Kompatibilität – UITabBarAppearance per #unavailable(iOS 26)

Auf iOS 17–25 setzt UITabBarAppearance weiterhin die Theme-Farben
(kein Liquid Glass → kein Konflikt, kein Flicker).
Auf iOS 26+ bleibt der Block weg, Liquid Glass + .preferredColorScheme
übernehmen die Tab-Bar.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-23 14:31:59 +02:00
parent 0c8e78f49d
commit 2c274ff4ae
+28 -3
View File
@@ -135,15 +135,40 @@ struct NahbarApp: App {
applyTabBarAppearance(NahbarTheme.theme(for: themeID))
}
/// Setzt UINavigationBar-Appearance für das gegebene Theme.
/// Hinweis: UITabBarAppearance wird bewusst NICHT gesetzt in iOS 26 übernimmt
/// Liquid Glass die Tab-Bar automatisch; eigene Hintergründe interferieren damit.
/// Setzt UIKit-Appearance für das gegebene Theme.
/// Auf iOS 26+ übernimmt Liquid Glass die Tab-Bar automatisch
/// eigene UITabBarAppearance-Hintergründe würden es stören.
/// Auf iOS 1725 wird die Tab-Bar explizit in Theme-Farben eingefärbt.
static func applyTabBarAppearance(_ theme: NahbarTheme) {
let border = UIColor(theme.borderSubtle)
let selected = UIColor(theme.accent)
let navBg = UIColor(theme.backgroundPrimary)
let titleColor = UIColor(theme.contentPrimary)
// iOS 1725: Liquid Glass existiert nicht; eigene UITabBarAppearance nötig.
// iOS 26+: Block weggelassen Liquid Glass + .preferredColorScheme übernehmen.
if #unavailable(iOS 26) {
let bg = UIColor(theme.backgroundPrimary)
let normal = UIColor(theme.contentTertiary)
let item = UITabBarItemAppearance()
item.normal.iconColor = normal
item.normal.titleTextAttributes = [.foregroundColor: normal]
item.selected.iconColor = selected
item.selected.titleTextAttributes = [.foregroundColor: selected]
let tabAppearance = UITabBarAppearance()
tabAppearance.configureWithOpaqueBackground()
tabAppearance.backgroundColor = bg
tabAppearance.shadowColor = border
tabAppearance.stackedLayoutAppearance = item
tabAppearance.inlineLayoutAppearance = item
tabAppearance.compactInlineLayoutAppearance = item
UITabBar.appearance().standardAppearance = tabAppearance
UITabBar.appearance().scrollEdgeAppearance = tabAppearance
}
let navAppearance = UINavigationBarAppearance()
navAppearance.configureWithOpaqueBackground()
navAppearance.backgroundColor = navBg