I'm developing database search app, and want to show a result view like this https://imgur.com/a/GUN6MiX .
The actionSheet wasn't correct answer.
HStack {
TextField("SearchText", text: $text)
.background(Color.white)
.shadow(radius: 10.0)
.foregroundColor(.black)
.padding(.trailing, -7)
Button(action: {
let r = getSearchResult(query: self.text)
if r is Int {
print("ErrorCode: \(r as! Int)")
} else {
self.holder.r = Result(sSearchResult: r as! SearchResult)
}
}){
Text("Search")
.font(.system(size: 10))
.foregroundColor(.white)
.padding(.leading, 3)
.padding(.trailing, 3)
}
}
To present a new view, wrap your view in a NavigationView
and use a NavigationLink
instead of a normal Button
. Put your new view in the destination parameter like NavigationLink(destination: SomeNewView()) { ... }
.
NavigationView {
HStack {
TextField("SearchText", text: $text)
.background(Color.white)
.shadow(radius: 10.0)
.foregroundColor(.black)
.padding(.trailing, -7)
NavigationLink(destination: SomeView()) {
Text("Search")
.font(.system(size: 10))
.foregroundColor(.white)
.padding([.leading, .trailing], 3)
}
}
}
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.