Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Created June 11, 2022 21:41
Show Gist options
  • Select an option

  • Save sturdysturge/fc076044bdee3922f9082eb7c778df09 to your computer and use it in GitHub Desktop.

Select an option

Save sturdysturge/fc076044bdee3922f9082eb7c778df09 to your computer and use it in GitHub Desktop.
import SwiftUI
@available(iOS 16.0, *)
struct ContentView: View {
@State var totalCapsules = 10
var body: some View {
VStack {
_CircleLayout(radius: 100) {
Group {
ForEach(1...totalCapsules, id: \.self) { index in
Capsule()
.frame(width: 25, height: 10)
.foregroundColor(
Color(
red: Double(index) / Double(totalCapsules),
green: 0,
blue: 0,
opacity: 1
)
)
.id(index)
}
}
}
Stepper("Capsules: \(totalCapsules)",
value: $totalCapsules, in: 1...100)
Button("Set To 50") {
withAnimation(.linear(duration: 1)) {
totalCapsules = 50
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment