Программируем под IOS
Anonymous
IOS 26 Uitabbarapearance Force Dark Mode
Сообщение
Anonymous » 10 июл 2025, 23:59
Я пытаюсь заставить свое приложение внедрить нижнюю панель вкладок в темный режим, когда система все еще находится в режиме света (переопределение темного режима). Очевидно, я могу заставить его работать
Код: Выделить всё
overrideUserInterfaceStyle = .dark
let appearance = UITabBarAppearance()
if #available(iOS 26, *) {
appearance.configureWithDefaultBackground()
}
< /code>
appdelegate < /p>
if #available(iOS 26, *) {
// no styling override
} else {
//navbar
let newNavBarApperance = PAppearance().getNavAppearance(style: .light)
let navAppearance = UINavigationBar.appearance()
navAppearance.standardAppearance = newNavBarApperance
navAppearance.tintColor = UIColor.white
navAppearance.isTranslucent = false
//tabbar
let newTabBarAppearance = PAppearance().getTabAppearance(style: .light)
let tabAppearance = UITabBar.appearance()
tabAppearance.standardAppearance = newTabBarAppearance
tabAppearance.tintColor = UIColor.white
tabAppearance.unselectedItemTintColor = UIColor.lightGray
tabAppearance.isTranslucent = false
navAppearance.scrollEdgeAppearance = newNavBarApperance
tabAppearance.scrollEdgeAppearance = newTabBarAppearance
}
< /code>
pappearance < /p>
static func makeTabBarAppearance(style: themeStyle) -> UITabBarAppearance {
let appearance = UITabBarAppearance()
if #available(iOS 26, *) {
appearance.configureWithDefaultBackground()
} else {
appearance.configureWithOpaqueBackground()
}
switch style {
case .dark:
if #unavailable(iOS 26) {
appearance.backgroundColor = .black
appearance.stackedLayoutAppearance.selected.iconColor = .white
appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.stackedLayoutAppearance.normal.iconColor = .white
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.white]
}
case .light:
if #unavailable(iOS 26) {
appearance.backgroundColor = UIColor(named: "Default") ?? .systemBackground
appearance.stackedLayoutAppearance.selected.iconColor = .white
appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.stackedLayoutAppearance.normal.iconColor = .white
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.white]
} else {
let selectedColor = UIColor.label
let normalColor = UIColor.secondaryLabel
appearance.stackedLayoutAppearance.selected.iconColor = selectedColor
appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: selectedColor]
appearance.stackedLayoutAppearance.normal.iconColor = normalColor
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: normalColor]
}
}
return appearance
}
< /code>
ViewController < /p>
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
guard UIApplication.shared.applicationState == .inactive else {
return
}
themeCheck()
}
func themeCheck() {
let theme = SharedPrefs.getPrefsStringValue(name: .theme)
switch theme {
case ThemeOverride.system.rawValue:
overrideUserInterfaceStyle = .unspecified
case ThemeOverride.light.rawValue:
overrideUserInterfaceStyle = .light
case ThemeOverride.dark.rawValue:
overrideUserInterfaceStyle = .dark
default:
overrideUserInterfaceStyle = .unspecified
}
updateNavBarForCurrentInterfaceStyle()
}
func updateNavBarForCurrentInterfaceStyle(){
let style: PAppearance.themeStyle =
traitCollection.userInterfaceStyle == .dark ? .dark : .light
let navAppearance = PAppearance.makeNavigationAppearance(style: style)
let tabAppearance = PAppearance.makeTabBarAppearance(style: style)
navigationController?.navigationBar.standardAppearance = navAppearance
navigationController?.navigationBar.scrollEdgeAppearance = navAppearance
tabBarController?.tabBar.standardAppearance = tabAppearance
tabBarController?.tabBar.scrollEdgeAppearance = tabAppearance
}
Подробнее здесь:
https://stackoverflow.com/questions/796 ... -dark-mode
1752181156
Anonymous
Я пытаюсь заставить свое приложение внедрить нижнюю панель вкладок в темный режим, когда система все еще находится в режиме света (переопределение темного режима). Очевидно, я могу заставить его работать [code]overrideUserInterfaceStyle = .dark let appearance = UITabBarAppearance() if #available(iOS 26, *) { appearance.configureWithDefaultBackground() } < /code> appdelegate < /p> if #available(iOS 26, *) { // no styling override } else { //navbar let newNavBarApperance = PAppearance().getNavAppearance(style: .light) let navAppearance = UINavigationBar.appearance() navAppearance.standardAppearance = newNavBarApperance navAppearance.tintColor = UIColor.white navAppearance.isTranslucent = false //tabbar let newTabBarAppearance = PAppearance().getTabAppearance(style: .light) let tabAppearance = UITabBar.appearance() tabAppearance.standardAppearance = newTabBarAppearance tabAppearance.tintColor = UIColor.white tabAppearance.unselectedItemTintColor = UIColor.lightGray tabAppearance.isTranslucent = false navAppearance.scrollEdgeAppearance = newNavBarApperance tabAppearance.scrollEdgeAppearance = newTabBarAppearance } < /code> pappearance < /p> static func makeTabBarAppearance(style: themeStyle) -> UITabBarAppearance { let appearance = UITabBarAppearance() if #available(iOS 26, *) { appearance.configureWithDefaultBackground() } else { appearance.configureWithOpaqueBackground() } switch style { case .dark: if #unavailable(iOS 26) { appearance.backgroundColor = .black appearance.stackedLayoutAppearance.selected.iconColor = .white appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: UIColor.white] appearance.stackedLayoutAppearance.normal.iconColor = .white appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.white] } case .light: if #unavailable(iOS 26) { appearance.backgroundColor = UIColor(named: "Default") ?? .systemBackground appearance.stackedLayoutAppearance.selected.iconColor = .white appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: UIColor.white] appearance.stackedLayoutAppearance.normal.iconColor = .white appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.white] } else { let selectedColor = UIColor.label let normalColor = UIColor.secondaryLabel appearance.stackedLayoutAppearance.selected.iconColor = selectedColor appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: selectedColor] appearance.stackedLayoutAppearance.normal.iconColor = normalColor appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: normalColor] } } return appearance } < /code> ViewController < /p> override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) guard UIApplication.shared.applicationState == .inactive else { return } themeCheck() } func themeCheck() { let theme = SharedPrefs.getPrefsStringValue(name: .theme) switch theme { case ThemeOverride.system.rawValue: overrideUserInterfaceStyle = .unspecified case ThemeOverride.light.rawValue: overrideUserInterfaceStyle = .light case ThemeOverride.dark.rawValue: overrideUserInterfaceStyle = .dark default: overrideUserInterfaceStyle = .unspecified } updateNavBarForCurrentInterfaceStyle() } func updateNavBarForCurrentInterfaceStyle(){ let style: PAppearance.themeStyle = traitCollection.userInterfaceStyle == .dark ? .dark : .light let navAppearance = PAppearance.makeNavigationAppearance(style: style) let tabAppearance = PAppearance.makeTabBarAppearance(style: style) navigationController?.navigationBar.standardAppearance = navAppearance navigationController?.navigationBar.scrollEdgeAppearance = navAppearance tabBarController?.tabBar.standardAppearance = tabAppearance tabBarController?.tabBar.scrollEdgeAppearance = tabAppearance } [/code] Подробнее здесь: [url]https://stackoverflow.com/questions/79697423/ios-26-uitabbarappearance-force-dark-mode[/url]
IOS 26 Uitabbarapearance Force Dark Mode
Anonymous »
10 июл 2025, 20:44 » в форуме
IOS
Я пытаюсь заставить свое приложение внедрить нижнюю панель вкладок в темный режим, когда система все еще находится в режиме света (переопределение темного режима). Очевидно, я могу заставить его работать
overrideUserInterfaceStyle = .dark
let...
0 Ответы
2 Просмотры
Последнее сообщение Anonymous
10 июл 2025, 20:44
Uitabbarapparance Force Dark Mode [закрыто]
Anonymous »
25 июл 2025, 01:03 » в форуме
IOS
Я пытаюсь внедрить нижнюю панель вкладок в темный режим, когда система все еще находится в режиме света (переопределение темного режима). Я могу заставить его работать в iOS ниже V26, но, похоже, нет способа заставить нижнюю панель в темный режим....
0 Ответы
5 Просмотры
Последнее сообщение Anonymous
25 июл 2025, 01:03
0 Ответы
54 Просмотры
Последнее сообщение Anonymous
03 ноя 2024, 15:54
Преодолеть Outlook Dark Mode Color Invert
Anonymous »
28 янв 2025, 13:32 » в форуме
CSS
Я знаю, что есть много тем, что касается этих проблем, но я не мог найти решение и не уверен, как его решить. цвета.
Я добавил! а также добавил легкий фон-image , а также добавил метатеги
Я не знаю, что я делаю неправильно, или как я могу...
0 Ответы
9 Просмотры
Последнее сообщение Anonymous
28 янв 2025, 13:32
Преодолеть Outlook Dark Mode Color Invert
Anonymous »
28 янв 2025, 14:48 » в форуме
CSS
Я знаю, что есть много тем, что касается этих проблем, но я не мог найти решение и не уверен, как его решить. цвета.
Я добавил! а также добавил легкий фон-image , а также добавил метатеги
Я не знаю, что я делаю неправильно, или как я могу...
0 Ответы
12 Просмотры
Последнее сообщение Anonymous
28 янв 2025, 14:48