Skip to content

Instantly share code, notes, and snippets.

@Arrlindii
Created December 6, 2019 22:23
Show Gist options
  • Select an option

  • Save Arrlindii/a1ec1197e707db26ce4d989283d04337 to your computer and use it in GitHub Desktop.

Select an option

Save Arrlindii/a1ec1197e707db26ce4d989283d04337 to your computer and use it in GitHub Desktop.
private struct RingShape: Shape {
var startAngle: Angle
var endAngle: Angle
let ringWidth: CGFloat
var animatableData: Double {
get {return endAngle.radians}
set {endAngle = Angle(radians: newValue)}
}
func path(in rect: CGRect) -> Path {
var path = Path()
let center = CGPoint(x: rect.midX, y: rect.midY)
let radius = (min(rect.width, rect.height) - ringWidth)/2
path.addArc(center: center,
radius: radius,
startAngle: startAngle,
endAngle: endAngle, clockwise: false)
return path.strokedPath(.init(lineWidth: ringWidth, lineCap: CGLineCap.round))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment