YouTube:
Source Code:
import SwiftUI
struct ContentView: View {
@State var content = ""
@State var isAlert = false
init() {
UITextView.appearance().backgroundColor = .clear
}
var body: some View {
VStack {
TextEditor(text: self.$content)
.background(.gray)
.frame(height: 200)
Button("My button") {
self.isAlert = true
}
.alert(isPresented: $isAlert) {
Alert(title: Text("Title"), message: Text(content))
}
}.padding()
}
}
#if DEBUG
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
Follow me on:
Comments