Created
December 6, 2019 22:23
-
-
Save Arrlindii/a1ec1197e707db26ce4d989283d04337 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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