I am new to Swift programming.
I am trying to change the content of each text and the colours with onHover as follows.
@State var isHover = false
@State var text = "OUT"
...
let textlist = [text, text]
VStack {
ForEach(0 ..< textlist.count, id: \.self){ index in
Text(textlist[index])
.foregroundColor(self.isHover ? Color.yellow : Color.white)
.onHover(perform: { flag in
self.isHover = flag
if flag {
self.text = "IN"
}else{
self.text = "OUT"
}
})
}
}
The result was that the contents of both were changed to "IN" from "OUT" and the colours yellow on a mouse over.
I just want to change each which a mouse is over.
How can I fix this problem?
Thank you.
Post
Replies
Boosts
Views
Activity
I am new to Swift programming.
To start with, I want to simply make a button as a Mac OS application.
What I want to do are as follows.
One is making the button size (the blue part) bigger.
Two is to be able to click the blue part.
But I got the result like the image.
I have no idea what I am going to do.
So I would like you to help me.
Thank you.