title: when tab bar background switch to dark, change tab bar items border color also
body: <p>I have small SwiftUI app, tab bar items have two color, selected have blue color and unselected have gray color and when I click the tab bar items , background switching to the dark color,  and I want to change tab bar items border color like selected will have blue color, unselected will have red color when background switch to dark color , is it possible?</p>
  <p><strong>DemoView:</strong></p>
  <pre><code>struct DemoView: View {
  
      let tabBar = UITabBar.appearance()
  
      init() {
          tabBar.barTintColor = UIColor.black
      }
  
      @State private var selectedTab = 0    // preserves selected tab
  
      var body: some View {
          TabView(selection: $selectedTab) {
              Text(&quot;FirstView&quot;)
                  .tabItem{
                      Image(systemName: &quot;homekit&quot;)
                      Text(&quot;First&quot;)
                  }.tag(0)
              
              Text(&quot;SecondView&quot;)
                  .tabItem{
                      Image(systemName: &quot;heart&quot;)
                      Text(&quot;Second&quot;)
                  }.tag(1)
              Text(&quot;ThirdView&quot;)
                  .tabItem {
                      Image(systemName: &quot;video&quot;)
                      Text(&quot;Third&quot;)
                      
                  }.tag(2)
          }
          
          .onAppear {
              setTabViewBackground()  // called, because `id` is below
          }
          .id(selectedTab)   // recreates entire above view with new tabbar
           
      }
  
      func setTabViewBackground() {
          tabBar.barTintColor = selectedTab != 0 ? .black : .white
             
      }
  }
  </code></pre>
  <p><strong>screenshot</strong></p>
  <p><a href="https://i.stack.imgur.com/jGx9B.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jGx9B.jpg" alt="enter image description here" /></a></p>