diff --git a/Mastodon/Scene/Settings/Cell/SettingsToggleTableViewCell.swift b/Mastodon/Scene/Settings/Cell/SettingsToggleTableViewCell.swift index 419f24d61..4926dbfce 100644 --- a/Mastodon/Scene/Settings/Cell/SettingsToggleTableViewCell.swift +++ b/Mastodon/Scene/Settings/Cell/SettingsToggleTableViewCell.swift @@ -20,7 +20,6 @@ class SettingsToggleTableViewCell: UITableViewCell { private(set) lazy var switchButton: UISwitch = { let view = UISwitch(frame:.zero) - view.onTintColor = contentView.window?.tintColor ?? .label return view }() @@ -49,8 +48,15 @@ class SettingsToggleTableViewCell: UITableViewCell { accessoryView = switchButton textLabel?.numberOfLines = 0 + updateAppearance() switchButton.addTarget(self, action: #selector(switchValueDidChange(sender:)), for: .valueChanged) } + + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + + updateAppearance() + } } @@ -72,4 +78,16 @@ extension SettingsToggleTableViewCell { switchButton.isOn = enabled ?? false } + private func updateAppearance() { + switchButton.onTintColor = { + switch traitCollection.userInterfaceStyle { + case .dark: + // set default green for Dark Mode + return nil + default: + // set tint black for Light Mode + return self.contentView.window?.tintColor ?? nil + } + }() + } }