Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created June 23, 2020 16:51
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 stevencurtis/3ef27e4c5604b69683a144caeb50eddc to your computer and use it in GitHub Desktop.
Save stevencurtis/3ef27e4c5604b69683a144caeb50eddc to your computer and use it in GitHub Desktop.
changescode
import SwiftUI
struct ChangeExampleView: View {
@State private var yourText = "Enter Your Text"
var body: some View {
Background {
TextEditor(text: $yourText)
.frame(width: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/, height: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/, alignment: .top)
}
.onChange(of: yourText) { newValue in
print("$yourText changed to \(yourText)!")
}
.onTapGesture {
self.endEditing()
}
}
private func endEditing() {
UIApplication.shared.endEditing()
}
}
struct ChangeExampleView_Previews: PreviewProvider {
static var previews: some View {
ChangeExampleView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment