Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SwiftUI button implementation with image that is changed on press, without default highlighting
Image(!isPressed ? "imageNormal" : "imagePressed")
.resizable()
.overlay(
GeometryReader { geometry in
Button(action: { }, label: {
Text("")
.frame(width: geometry.size.width, height: geometry.size.height)
.contentShape(Rectangle())
})
.buttonStyle(PlainButtonStyle())
.pressAction {
isPressed = true
} onRelease: {
isPressed = false
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.