简体   繁体   中英

Present the old small title of UINavigationBar in SwiftUI NavigationView

Until now the default displayMode for UINavigationItem was small title and it changed in SwiftUI to be large by default.

Is it possible to use the old small title style?

iOS 14+

Starting from iOS 14 the navigationBarTitle modifier is deprecated .

Instead we should:

"Use navigationTitle( :) with navigationBarTitleDisplayMode( :)"

List {
    Text("Text")
}
.navigationTitle("Title")
.navigationBarTitleDisplayMode(.inline)

It is possible by passing displayMode: .inline attribute to navigationBarTitle()

NavigationView {
  List {
    Text("Text")
  }.navigationBarTitle(Text("Title"), displayMode: .inline)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM