Code: Select all
{
let tabBar = self.tabBar
if #available(iOS 13.0, *) {
let appearance = UITabBarAppearance()
appearance.stackedLayoutAppearance.selected.iconColor = .systemGreen
appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: UIColor.systemGreen]
appearance.stackedLayoutAppearance.normal.iconColor = .systemRed
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.systemRed]
tabBar.standardAppearance = appearance
tabBar.scrollEdgeAppearance = appearance
} else {
tabBar.tintColor = .systemGreen
tabBar.unselectedItemTintColor = .systemRed
}
tabBar.items?.forEach { item in
item.image = item.image?.withRenderingMode(.alwaysTemplate)
item.selectedImage = item.selectedImage?.withRenderingMode(.alwaysTemplate)
}
}

Ich erwarte, dass die Farbe des Symbols auch bei nicht ausgewählten Registerkartenelementen mit dem Text übereinstimmt.

Mobile version