SwiftUI NavigationBarTitle subtitle that goes above, like in Apple Music?

Viewed 1490

In the latest Apple Music (iOS 13), the For You tab has the current date as a "subtitle" that sits above the title of the view (named "For You"). How would one implement a subtitle like this in SwiftUI?

I can't seem to find a field that allows a subtitle. You are only able to change the normal title, via:

.navigationBarTitle("For You")

Is there anything like this?

.navigationBarSubTitle("Tuesday, 29 October")

1 Answers

That's the only tab in the app that does not use a navigation view. Swipe up and you will see the navigation bar (or whatever this is) disappear. For the other four tabs, the title will remain on top of the screen.

Using UIKit, this behavior can e.g. be achieved by using UITableView.tableHeaderView.

With regards to SwiftUI, try something like this for your list (if it's not a list, just adapt the code):

List {
    VStack(alignment: .leading) {
        Text("Tuesday, 29 October".uppercased())
            .foregroundColor(.secondary)
            .font(.subheadline)
        Text("For You")
            .font(.largeTitle)
    }
    ForEach(…) {
        /*.the actual content of the list view */
    }
}
Related