Last active
November 28, 2021 04:27
Star
You must be signed in to star a gist
AutoOpenTextField.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
@available(iOS 15.0, *) | |
struct AutoOpenTextField: View { | |
@State private var name = "" | |
@FocusState var isFocused: Bool { | |
didSet { | |
DispatchQueue.main.async { | |
isFocused = true | |
} | |
} | |
} | |
var body: some View { | |
TextField("Name", text: $name) | |
.focused($isFocused) | |
.onAppear { | |
isFocused = false | |
} | |
} | |
} | |
@available(iOS 15.0, *) | |
struct AutoOpenTextField_Previews: PreviewProvider { | |
static var previews: some View { | |
AutoOpenTextField() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
default.mov