1

I have two texts that I would like to display in a navigation title:

...
        .navigationTitle(Text(getTitle()) + Text(" (\(selection + 1)/\(sequenceObject.homeElements.count))"))

However, the first text could become too large after user input and the second text would no longer be displayed (

This is a verly long navigation ti...

). But the second text must always be visible!!! My wish text layout of the navigation title would be:

This is a very long...second text

Any ideas?

Best regards!

SwiftUI_Max
  • 201
  • 2
  • 6

1 Answers1

0

You need to do it a little bit different. .navigationTitle is not made for a long title, but if you do need a long title, use the Text modifier like this:

NavigationView{
            VStack(){
                //"your Code
            }
            .navigationBarTitleDisplayMode(.large)
            .toolbar {
                ToolbarItem(placement: .navigationBarLeading) {
                    VStack {
                        Text("This is a very long title").font(.largeTitle).bold()
                        Text("with our subtitle").font(.subheadline)
                        //you can also do .font(.largeTitle).bold() here
                    }
                }
            }
        }
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Iskandir
  • 937
  • 1
  • 9
  • 21
  • Hey. Thank you really much! Unfortunately I need a large naviagtion title (.navigationbardisplaymode(.large)) and thats why this wouldn´t work for me.. – SwiftUI_Max Apr 14 '22 at 16:52