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:
@@ -135,15 +135,40 @@ struct NahbarApp: App {
|
|||||||
applyTabBarAppearance(NahbarTheme.theme(for: themeID))
|
applyTabBarAppearance(NahbarTheme.theme(for: themeID))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Setzt UINavigationBar-Appearance für das gegebene Theme.
|
/// Setzt UIKit-Appearance für das gegebene Theme.
|
||||||
/// Hinweis: UITabBarAppearance wird bewusst NICHT gesetzt – in iOS 26 übernimmt
|
/// Auf iOS 26+ übernimmt Liquid Glass die Tab-Bar automatisch –
|
||||||
/// Liquid Glass die Tab-Bar automatisch; eigene Hintergründe interferieren damit.
|
/// eigene UITabBarAppearance-Hintergründe würden es stören.
|
||||||
|
/// Auf iOS 17–25 wird die Tab-Bar explizit in Theme-Farben eingefärbt.
|
||||||
static func applyTabBarAppearance(_ theme: NahbarTheme) {
|
static func applyTabBarAppearance(_ theme: NahbarTheme) {
|
||||||
let border = UIColor(theme.borderSubtle)
|
let border = UIColor(theme.borderSubtle)
|
||||||
let selected = UIColor(theme.accent)
|
let selected = UIColor(theme.accent)
|
||||||
let navBg = UIColor(theme.backgroundPrimary)
|
let navBg = UIColor(theme.backgroundPrimary)
|
||||||
let titleColor = UIColor(theme.contentPrimary)
|
let titleColor = UIColor(theme.contentPrimary)
|
||||||
|
|
||||||
|
// iOS 17–25: 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()
|
let navAppearance = UINavigationBarAppearance()
|
||||||
navAppearance.configureWithOpaqueBackground()
|
navAppearance.configureWithOpaqueBackground()
|
||||||
navAppearance.backgroundColor = navBg
|
navAppearance.backgroundColor = navBg
|
||||||
|
|||||||
Reference in New Issue
Block a user