2

I don't know how to change the background of the TabBar by an Image (I try to change the background of TabBar, not try to change the TabBar Icon by an Image) I tried to set an background to my TabBar such as the TabBar of the program on the right I tried to set an background to my TabBar such as the TabBar of the program on the right

Horitsu Potter
  • 107
  • 1
  • 6

1 Answers1

3

Assuming you have right image in your assets catalog (or prepared in advance), you can set it in view's init, like

struct ContentView: View {
    init() {
        let appearance = UITabBarAppearance()
        appearance.configureWithOpaqueBackground()
        appearance.backgroundImage = UIImage(named: "image")
        UITabBar.appearance().scrollEdgeAppearance = appearance
    }

   // ... other code
}
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Asperi
  • 228,894
  • 20
  • 464
  • 690