leontedev / AnimatedBarCharts

SwiftUI - Animated Progress Bar Charts experiment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Animated Progress Bar Charts

A SwiftUI experiment on capsules. Starting point tutorial: Let’s Build That App

gif.gif screen2.png

  • ZStack with a colored background:
Color("appBackground").edgesIgnoringSafeArea(.all)
  • Adding a “Color Literal” (autocompletion) to pick colors and use them directly in code. The Color() view is necessary.
  • Creating a “Progress Bar” using two Capsules()
ZStack(alignment: .bottom) {
    Capsule().frame(width: 30, height: 200)
        .foregroundColor(Color("emptyCapsule"))
    Capsule().frame(width: 30, height: value)
        .foregroundColor(Color("filledCapsule"))
}
  • Adding animation on the entire HStack view which contains all the horizontal progress bars using the .animation(.default) modifier.

About

SwiftUI - Animated Progress Bar Charts experiment


Languages

Language:Swift 100.0%