I made a View called customText, you can see the codes down. I am using customText inside my ContentView. I want to give extra Possibility to my customText in this way that I want extend this View with Special command, that command or function would be called .stringOfText().
My Goal:
For giving light what I am looking for: I want be able to type this code in my ContentView:
struct ContentView: View {
var body: some View {
customText().stringOfText("Omid")
}
}
PS: I know that I can send that data with @Binding or many other ways! but I am interested to the way I mentioned at my Goal.
struct ContentView: View {
var body: some View {
customText()
}
}
struct customText: View {
@State var stringOfText = "Hello, world!"
var body: some View
{
Text(stringOfText)
}
}