Created
June 23, 2020 16:51
-
-
Save stevencurtis/3ef27e4c5604b69683a144caeb50eddc to your computer and use it in GitHub Desktop.
changescode
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 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