如何在 swift ui 的导航视图中的大标题下方添加副标题?

How to add a subtitle below a large title in a navigation view in swift ui?

如何在这样定义的大标题下添加副标题?

NavigationView{

        VStack(){
           //"Some code" 
        }
        .navigationTitle("Analytics")
}

您可以尝试这样的操作:

 NavigationView{
            VStack(){
                //"Some code"
            }
            .navigationBarTitleDisplayMode(.large)
            .toolbar {
                ToolbarItem(placement: .navigationBarLeading) {
                    VStack {
                        Text("Title").font(.largeTitle).bold()
                        Text("Subtitle").font(.subheadline)
                    }
                }
            }
        }

似乎“navigationSubtitle”仅适用于 macOS,这是 ios 中的另一种方式:

        .navigationBarItems(leading: VStack {
            Text("Analytics").font(.largeTitle).bold()
            Text("Subtitle")
        })

编辑更新:

你也可以试试这个,但字体选择会有所损失:

.navigationTitle("Subtitle") 
.navigationBarItems(leading: Text("Analytics").font(.largeTitle).bold())

我已经找到了我正在寻找的解决方案:基本上创建屏幕顶部,因为它通常没有 navigationView,然后在下面添加一个滚动视图。

HStack {
    VStack(alignment: .leading, spacing: 5) {
        Text("Title")
             .font(.largeTitle)
             .foregroundColor(Color(UIColor.label))
             .fontWeight(.bold)
                        
        Text("subtitle")
             .font(.subheadline)
             .foregroundColor(Color(UIColor.label))
     }
                
     Spacer()         
 }
 .padding()
            
            
            
 ScrollView(.vertical, showsIndicators: false) {}