如何在iOS 13中设置选项卡栏标题?

如何在iOS 13中设置选项卡栏标题?,ios,swiftui,Ios,Swiftui,我试图在选项卡栏的标题字段中设置更大的字体,但它不起作用。我尝试的更改了视图中图标的大小和文本字段的字体。栏中的标题保持不变。正如你所看到的,我尝试了很多方法(注释行),但它们都不起作用 struct DetailView: View { var vehicle: Vehicle var body: some View { TabView { DataView() .tabItem { Text("Dane&q

我试图在选项卡栏的标题字段中设置更大的字体,但它不起作用。我尝试的更改了视图中图标的大小和文本字段的字体。栏中的标题保持不变。正如你所看到的,我尝试了很多方法(注释行),但它们都不起作用

struct DetailView: View {

var vehicle: Vehicle

var body: some View {
    
    TabView {
       DataView()
        .tabItem {
            Text("Dane")
            .font(.system(size: 18.0, weight: .bold, design: .rounded))
            Image(systemName: "list.bullet")
//.font(.system(size: 30)).bold()//(Font.system(.largeTitle, design: .rounded).weight(.heavy).bold())
        }
        
        RefuelingListView()
            .font(.system(size: 20.0, weight: .bold, design: .rounded))
            .tabItem {
                Text("Wpisy")
                .bold()
                .font(Font.system(.largeTitle, design: .rounded).weight(.heavy))
                Image(systemName: "list.bullet")
               // .font(.system(size: 19))
        }//.font(.largeTitle)
   // }
         //   .textFieldStyle(PlainTextFieldStyle()).font(.system(size: 20))
 //        .onAppear() {
//            UITabBar.appearance().tintColor = .red
    }
    //.font(Font.system(.largeTitle, design: .rounded).weight(.heavy))
}
}

您可以尝试为选项卡栏添加自定义初始值设定项,如下所示:

struct DetailView: View {

var vehicle: Vehicle

init() {
    UITabBarItem.appearance().setTitleTextAttributes([.font : UIFont.systemFont(ofSize: 20)], for: [])
}

var body: some View {
        // Rest of code
    }
}

好主意,但我在.onAppear(){}中将其设置在选项卡的末尾。谢谢。