0

I am trying to work with onHover(); I want my foreground color to change when I move the cursor on top of the Text(), but it did not work.

Why?

import SwiftUI


struct ContentView: View {

@State private var overText = false

var body: some View {
    Text("Hello, World!")
        .foregroundColor(overText ? .green : .red)
        .onHover { over in
            overText = over
        }
}
}
Steven-Carrot
  • 2,368
  • 2
  • 12
  • 37

0 Answers0