TabBarItem cambiar el color del texto fracaso

  • Un estudio reciente Swift, a partir de los proyectos, se encontró tabBarItem no se selecciona el color del texto no funciona, el sistema por defecto es de color gris
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.green], for: .selected)
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.red], for: .normal)

Pedido a la siguiente, se dice que es un problema no es específico iOS13 pregunta IOS 13, él no fue Certificación

soluciones

IOS menores de 13 años UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.red], for: .normal)propiedad se establece en estado normal ya no funciona, Apple sacó unos cuantos ciegos a través de este, no es incómodo

tabBar.tintColor = UIColor.blue
// 通过UITabBar.appearance() 点不出unselectedItemTintColor属性, 可以直接硬敲
// UITabBar.appearance().unselectedItemTintColor = UIColor.red
tabBar.unselectedItemTintColor = UIColor.red

o

UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.green], for: .selected)
tabBar.unselectedItemTintColor = UIColor.red

Supongo que te gusta

Origin www.cnblogs.com/gchlcc/p/12564110.html
Recomendado
Clasificación