4

Freshman of ios developer.Instead of Objective-c/UIKit, I choose swift/swiftUI to start this.

Wanna change background of TabView in swiftUI, first I tried to use background modifier but useless, then I found nothing in developer documents to resolve this issue.

Finally I found a solution here as below(use UITabBar), it works.

So I'm so confused about this:

  1. SwiftUI didn't provide a way to change background color of TabView?We should use UIKit/UITabBar to do this? SwiftUI is just a wrapper of UIKit?
  2. If the answer of question 1 is YES, Why swiftUI didn't provide it?This is because of imperfection of swiftUI or just Apple didn't want swiftUI developers to change background color of TabBar?In particular scene which we really to do something but swiftUI can't afford it, should i use UIKit additional?
  3. I'm not a iOS developer, just be insterested in doing this.Should I learn UIKit in swift, or even Objective-c first?Is that a mistake to start with swift/swiftUI?
import SwiftUI

struct HomeView: View {
    // Use UITabBar to do this.
    init() {
        UITabBar.appearance().backgroundColor = UIColor(.orange)
    }

    var body: some View {
        TabView {
            ClockScreen()
                .tabItem {
                    Image(systemName: "heart.fill")
                    Text("Favourites")
                }
            ScheduleScreen()
                .tabItem {
                    Image(systemName: "mappin.circle.fill")
                    Text("Friends")
                }
            ProfileScreen()
                .tabItem {
                    Image(systemName: "person.fill")
                    Text("Nearby")
                }
        }
    }
}

snowyCN
  • 49
  • 1
  • 3
  • Does this answer your question? [Change Tabbed View Bar Color SwiftUI](https://stackoverflow.com/questions/56969309/change-tabbed-view-bar-color-swiftui) – Abhinav Mathur Feb 13 '22 at 09:24
  • 1
    @AbhinavMathur sorry bro this is not what I want. Using UITabBar work obviously, but I want to know is there any way to use swiftUI directly without UIKit.And also I leave more questions in the list. – snowyCN Feb 13 '22 at 11:57

0 Answers0