I have a button 'SelectedColor()' which runs a func. The func randomly selects a color name from an array. I then want to place the result into a field on the layout but can't think how to do this. Can someone assist with this please?
On an iPad, so no code, sorry.
In your View, above your body, add a @State variable, such as @State var color = “Green”
Then, in the button, make the action color = SelectedColor.
You will need to modify your function to return chosenColor.
Fantastic. That works great. Thanks.