Created
January 27, 2020 19:42
-
-
Save filimo/efdd3b65191a172c6bd28583fb61a3ad to your computer and use it in GitHub Desktop.
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 ScaleButtonStyle: ButtonStyle { | |
public func makeBody(configuration: Configuration) -> some View { | |
print(configuration.isPressed) | |
return configuration.label | |
.frame(width: 200, height: 200) | |
.scaleEffect(configuration.isPressed ? 0.9 : 1) | |
.animation(.easeInOut) | |
} | |
} | |
struct SimpleScaleButtonStyle: ButtonStyle { | |
public func makeBody(configuration: Configuration) -> some View { | |
configuration.label.scaleEffect(configuration.isPressed ? 0.9 : 1.0) | |
} | |
} | |
struct SimpleCard: View { | |
var body: some View { | |
ZStack { | |
Button(action: { | |
}) { | |
Rectangle() | |
}.buttonStyle(ScaleButtonStyle()) | |
Button(action: { | |
}) { | |
Rectangle() | |
.foregroundColor(Color.red) | |
.frame(width: 50, height: 50) | |
}.buttonStyle(SimpleScaleButtonStyle()) | |
} | |
} | |
} | |
struct SimpleCard_Previews: PreviewProvider { | |
static var previews: some View { | |
SimpleCard() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment