0

The default color of inactive TabBarItem icon is gray

enter image description here

How can I change the default color?

XCode 14.2
SwiftUI 4.x.x

softshipper
  • 32,463
  • 51
  • 192
  • 400

2 Answers2

0

You can set the color with appearance settings:

struct ContentView: View {
  init() {
     UITabBar.appearance().unselectedItemTintColor = UIColor.green
  }

  var body: some View {
     ...
  }
}

otherwise check another approach shared here: https://stackoverflow.com/a/64727573/4977439

Oleg
  • 591
  • 5
  • 14
  • Is there no any solution with the modifier? – softshipper Feb 08 '23 at 09:23
  • There is no OOTB modifier, but you can build your own based on the solution in the provided link, or this one: https://stackoverflow.com/questions/59969911/programmatically-detect-tab-bar-or-tabview-height-in-swiftui/59972635#59972635, but that's basically wrapper over UIKit component to track rendering event and change color dynamically. I would recommend following the Appearance approach as you won't have any issues with runtime. – Oleg Feb 08 '23 at 09:59
  • What is the recommended approach? – softshipper Feb 08 '23 at 12:33
  • the recommended approach here in this answer. – Oleg Feb 08 '23 at 15:59
-1

If that is systemImage, set the icon in systemName, then there is a mac app called SF Symbols where you can change the color to the emoji you want!

junha
  • 9
  • 3
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 10 '23 at 14:17