Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaisukeNagata/9d04890c64ed32d9ba6e81ea39261fa3 to your computer and use it in GitHub Desktop.
Save DaisukeNagata/9d04890c64ed32d9ba6e81ea39261fa3 to your computer and use it in GitHub Desktop.
SwiftUI_onHover
import SwiftUI
struct ContentView: View {
@State private var hovering = false
var body: some View {
Button(action: {
self.hovering.toggle()
}) {
Text("Button")
}
.buttonStyle(PlainButtonStyle())
.scaleEffect(hovering ? 1.5 : 1.0)
.animation(.spring())
.padding()
.background(Color.green)
.cornerRadius(10)
.onHover { isHovered in
self.hovering = isHovered
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment