Created
July 12, 2020 14:02
-
-
Save DaisukeNagata/9d04890c64ed32d9ba6e81ea39261fa3 to your computer and use it in GitHub Desktop.
SwiftUI_onHover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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