1

I have been trying this for a while but with everything I do, I don't get the desired result. To be clear, I don't want to use the inline display mode, I want a large title but centered.

Here is what I'm trying to do:

ScreenShot

My best attempt was a toolbar like this

.navigationBarTitleDisplayMode(.inline)
.toolbar {
    ToolbarItem(placement: .principal) {
        Text("Title")
            .font(.manrope(.bold(), size: 30)
            .accessibilityAddTraits(.isHeader)
            .padding(.top, 75)
    }
}

While this worked fine on the first page when you navigate and/or return to a page, the heading disappears.

Ideally, I'd like to center the Title using an initializer as I did for the font:

init() {
        UINavigationBar.appearance().largeTitleTextAttributes = [.font : UIFont(name: "Manrope-Bold", size: 30)!]
    }
Arnav Motwani
  • 707
  • 7
  • 26

1 Answers1

2

Well, if you dont want the inline display mode my first idea would be to use a Text with parameters.

Something like

...
Text("Settings")
.font(.largetitle)
.frame(maxWidth: .infinity, alignment: .center)
...

Put that in front of your menu and this looks quite nice i guess.

Iskandir
  • 937
  • 1
  • 9
  • 21