this is about SwiftUI.
my custom PNG 75x75, Black, Background Transparent TabBar icons doesn't get the color. My Icons are always black, no matter if there active or not. What I'm doing wrong?
Text("Test")
.tabItem {
Image("MyIcon")
Text("MyName")
}.tag(0)
Assuming you’ve created a SwiftUI project using Xcode 12, let’s start with a simple text view like this: To embed this text view in a tab bar, all you need to do is wrap it with the TabView component and set the tab item description by attaching the .tabItem modifier like this: This will create a tab bar with a single tab item.
A tab bar appears at the bottom of an app screen and let users quickly switch between different functions of an app. In UIKit, you use the UITabBarController to create the tab bar interface. For the SwiftUI framework, it provides a UI component called TabView for developers to display tabs in the apps.
First we need to create our enum with the images and names for Tab Bar icons. The images that I will use will be from SF Symbols After this we need to build our Tab Button inside CustomTabBarView, but first we need to define tow variables, one for our current tab bar and another for matched geometry effect.
To ensure that the whole plus tab bar icon is placed slightly above the tab view, we apply the .offset modifier to our ZStack. Our ZStack should be shifted upwards by half the height of the tab bar. Since our tab view is one-eight as high as the screen, we write:
The template mode should work here, like
Image("MyIcon")
.renderingMode(.template)
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