Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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")
}
like image 806
Abv Avatar asked Feb 02 '26 03:02

Abv


2 Answers

You could try something like this:

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

enter image description here

like image 108
Răzvan Rujoiu Avatar answered Feb 03 '26 19:02

Răzvan Rujoiu


Seems "navigationSubtitle" is only for macos, this is another way to do it in ios:

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

Edit update:

you could also try this, with some loss of font choice:

.navigationTitle("Subtitle") 
.navigationBarItems(leading: Text("Analytics").font(.largeTitle).bold())
like image 39
workingdog support Ukraine Avatar answered Feb 03 '26 19:02

workingdog support Ukraine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!