-
-
Save anupamchugh/b8b1f474fe2278ee194a28baf4901c25 to your computer and use it in GitHub Desktop.
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 | |
struct ContentView: View { | |
@State var currentText: String = "Hi How are you?" | |
@State var clearText: Bool = false | |
var body: some View { | |
VStack{ | |
TextEditor(text: $currentText) | |
.onChange(of: clearText) { value in | |
if clearText{ | |
currentText = "" | |
} | |
} | |
Button(action: {clearText = true}, label: { | |
Text("Clear Text Editor") | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment