I need to change the color of a tabItem badge in SwiftUI. I founded this pod https://github.com/jogendra/BadgeHub
Is it possible to use with SwiftUI?
I have tabItems:
TabView(selection: $selection) {
    FeaturedView(users: filteredUsers, usersCount: filteredUsersCount)
        .tabItem {
            Image(selection == 0 ? "ic_searchFill" : "ic_search").renderingMode(.template)
        }
        .tag(0)
    LikesView(userViews: self.userViews, userLikes: self.userLikes)
        .tabItem {
            Image(selection == 1 ? "ic_heartFill" : "ic_heart").renderingMode(.template)
        }
        .badge(userLikesCount)
        .tag(1)
    ConversationsView(conversations: conversations)
        .tabItem {
            Image("ic_chat").renderingMode(.template)
        }
        .badge(conversationsCount)
        .tag(2)
    SettingsView(user: user)
        .tabItem {
            Image(selection == 3 ?  "ic_profileFill" : "ic_profile").renderingMode(.template)
        }
        .tag(3)
}
Actually we can configure SwiftUI badge color as well, via appearance.

Tested with Xcode 13.4 / iOS 15.5
init() {
    UITabBarItem.appearance().badgeColor = .purple   // << here !!
}
var body: some View {
    TabView {
        Color.green.overlay(Text("One"))
            .tabItem { Image(systemName: "car") }
            .badge(4)
// ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With