Skip to content

Instantly share code, notes, and snippets.

@anupamchugh
Last active June 14, 2020 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anupamchugh/5af6b07f5efc1549df770c033297e7e1 to your computer and use it in GitHub Desktop.
Save anupamchugh/5af6b07f5efc1549df770c033297e7e1 to your computer and use it in GitHub Desktop.
struct ProgressBar: View {
@Binding var progress: Double
var body: some View {
GeometryReader { geometry in
ZStack(alignment: .leading) {
Rectangle()
.foregroundColor(Color.gray)
.opacity(0.3)
.frame(width: geometry.size.width, height: geometry.size.height)
Rectangle()
.foregroundColor(Color.blue)
.frame(width: geometry.size.width * CGFloat((self.progress)),
height: geometry.size.height)
.animation(.linear(duration: 0.5))
}
.cornerRadius(geometry.size.height / 2.0)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment