SwiftUI: how to make searchbar become first responder?

Viewed 109

I would like to make the searchbar become first responder as soon as the view appears. Unfortunately there is no @FocusState support yet / other calls to achieve this out-of-the-box. Is there another way of achieving this?

struct SearchDemo: View {
    
    @State var searchString : String = ""
    
    var body: some View {
        NavigationView {
            List{
                Text("...")
            }
            .searchable(text: $searchString)
        }
    }
}
0 Answers
Related