Search code examples
swiftswiftuinavigationview

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


How can I add a subtitle under a large title that was defined this way?

NavigationView{

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

Solution

  • I have found a solution to what I was looking for: basically create the top of the screen as it would normally be without a navigationView and then add a scrollview underneath.

    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) {}