Skip to content

Instantly share code, notes, and snippets.

@karthironald
Created May 28, 2020 03:15
Show Gist options
  • Save karthironald/733177e139ce91bc719509584f085234 to your computer and use it in GitHub Desktop.
Save karthironald/733177e139ce91bc719509584f085234 to your computer and use it in GitHub Desktop.
struct ContentView: View {
@State private var shouldAnimate = false
var body: some View {
HStack(alignment: .center, spacing: shouldAnimate ? 15 : 5) {
Capsule(style: .continuous)
.fill(Color.blue)
.frame(width: 10, height: 50)
Capsule(style: .continuous)
.fill(Color.blue)
.frame(width: 10, height: 30)
Capsule(style: .continuous)
.fill(Color.blue)
.frame(width: 10, height: 50)
Capsule(style: .continuous)
.fill(Color.blue)
.frame(width: 10, height: 30)
Capsule(style: .continuous)
.fill(Color.blue)
.frame(width: 10, height: 50)
}
.frame(width: shouldAnimate ? 150 : 100)
.animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true))
.onAppear {
self.shouldAnimate = true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment