Is there a way to remove extra space over navigation title (scribbled it in Red in below screenshot). I am working with iOS 15.
Code:
import SwiftUI
import Foundation
struct ContentView: View {
let names = ["Holly", "Josh", "Rhonda", "Ted"]
@State private var searchText = ""
/// A site name filter phrase entered by the user.
@State private var query: String = ""
var body: some View {
VStack {
NavigationView {
VStack {
List {
ForEach(searchResults, id: \.self) { name in
Text(name)
}
}
}
.searchable(
text: $query,
placement: .navigationBarDrawer(displayMode: .always),
prompt: "search"
)
.navigationTitle("Explore")
.background(Color.gray)
}
Spacer()
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color.gray)
}
var searchResults: [String] {
if searchText.isEmpty {
return names
} else {
return names.filter { $0.contains(searchText) }
}
}
}