E
E
errmaker2019-10-13 17:13:58
Swift
errmaker, 2019-10-13 17:13:58

Swift how to get a button programmatically?

Please tell me how to programmatically get to the button to change, for example, the text on it?

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            Text("Hello World")
                .frame(maxWidth: 100, maxHeight: 100)
            Button(action: /*@[email protected]*/{}/*@[email protected]*/)
            {
                Text(/*@[email protected]*/"Button"/*@[email protected]*/)
            }

            List {
                /*@[email protected]*/ /*@[email protected]*/Text("Content")/*@[email protected]*/
            }
            Button(action: tst) {
                Text(/*@[email protected]*/"Button"/*@[email protected]*/)
            }
        }
    }
}

func tst()
{
    button.Text = "ddddd"
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question