Created
January 7, 2021 19:00
-
-
Save hashemi/c13ad9284c9d1f68c6b5a79561a58b45 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 ContentView: View { | |
@State var tapped: Bool = false | |
var width: CGFloat { tapped ? 300 : 60 } | |
var color: Color { tapped ? .red : .yellow } | |
var body: some View { | |
Button(action: { tapped.toggle() }) { | |
ZStack { | |
Capsule().foregroundColor(color) | |
Image(systemName: "plus") | |
.foregroundColor(.white) | |
.font(.system(size: 25, weight: .bold, design: .rounded)) | |
} | |
.frame(width: width, height: 60, alignment: .leading) | |
}.animation(.spring()) | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment