I have the following code snippet that draws a circular sector shape:
When I preview it,
instead of a 45° sector clockwise, it draws a 315° sector counterclockwise.
Code Block swift struct CircularSector: Shape { let centralAngle: Angle func path(in rect: CGRect) -> Path { let radius = min(rect.width, rect.height) / 2 let center = CGPoint(x: rect.midX, y: rect.midY) var path = Path() path.addArc(center: center, radius: radius, startAngle: .degrees(0), endAngle: centralAngle, clockwise: true) path.addLine(to: center) path.closeSubpath() return path } }
When I preview it,
Code Block swift struct CircularSector_Previews: PreviewProvider { static var previews: some View { CircularSector(centralAngle: .degrees(45)).fill(Color.black) } } }
instead of a 45° sector clockwise, it draws a 315° sector counterclockwise.