Swiftui - How to Set the Title of a Navigationview to Large Title (Or Small)

How to add a subtitle below a large title in a navigation view in swift ui?

I have found a solution to what I was looking for: basically create the top of the screen as it would normally be without a navigationView and then add a scrollview underneath.

HStack {
VStack(alignment: .leading, spacing: 5) {
Text("Title")
.font(.largeTitle)
.foregroundColor(Color(UIColor.label))
.fontWeight(.bold)

Text("subtitle")
.font(.subheadline)
.foregroundColor(Color(UIColor.label))
}

Spacer()
}
.padding()



ScrollView(.vertical, showsIndicators: false) {}

SwiftUI: How to align a NavigationBarItem with a large title navigation title?

You can't. Because the Navigation Title is dynamic as it can change from small to big on scroll, at least you say otherwise, the UI does not allow you to set up the navigation items aligned vertically in other position other than the expected. That is right below the safe area. Is like giving a leading navigation item hides the back button. This is how Cocoa Touch either via SwiftUI or UIKIt works.



Related Topics



Leave a reply



Submit