Skip to content

Instantly share code, notes, and snippets.

@hashemi
Created January 7, 2021 19:00
Show Gist options
  • Save hashemi/c13ad9284c9d1f68c6b5a79561a58b45 to your computer and use it in GitHub Desktop.
Save hashemi/c13ad9284c9d1f68c6b5a79561a58b45 to your computer and use it in GitHub Desktop.
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