belotserkovtsev
belotserkovtsev

Reputation: 361

How to change tab item color in SwiftUI

I need my tabItem to be purple when active. Just like that:

tabview

Here's code sample:

// *some view*
.tabItem {
   Image(systemName: "square.and.pencil")
   Text("Задания")
}

Is there a way to do so?

Upvotes: 2

Views: 424

Answers (2)

Muhammad Shahzad
Muhammad Shahzad

Reputation: 208

Please try this

.tabItem {
   Image(systemName: "square.and.pencil")
   Text("Задания")
}.accentColor(.orange)

Upvotes: 1

Aviv Profesorsky
Aviv Profesorsky

Reputation: 174

Add .accentColor(.purple) right after the TabView closure

Upvotes: 3

Related Questions