Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Last active July 4, 2022 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sturdysturge/120e81f5b6e1978b8e5ccc5b5e6dbb3e to your computer and use it in GitHub Desktop.
Save sturdysturge/120e81f5b6e1978b8e5ccc5b5e6dbb3e to your computer and use it in GitHub Desktop.
import SwiftUI
struct FocusableTextField: View {
@Binding var text: String
@Binding var focusedBinding: Bool
@FocusState private var focused: Bool
var body: some View {
TextField("Text", text: $text)
.focused($focused)
.onChange(of: focusedBinding) { focusedBinding in
focused = focusedBinding
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment