struct DevTechieShape: Shape { func path(in rect: CGRect) -> Path { Path { path in path.move(to: CGPoint(x: rect.minX, y: rect.maxY)) path.addLine(to: CGPoint(x: rect.minX, y: rect.minY)) path.addCurve(to: CGPoint(x: rect.midX, y: rect.midY), control1: CGPoint(x: rect.minX, y: rect.minY), control2: CGPoint(x: rect.midX, y: rect.minY)) path.addCurve(to: CGPoint(x: rect.minX, y: rect.maxY), control1: CGPoint(x: rect.midX, y: rect.maxY), control2: CGPoint(x: rect.minX, y: rect.maxY)) path.addCurve(to: CGPoint(x: rect.minX, y: rect.maxY), control1: CGPoint(x: rect.midX, y: rect.midY), control2: CGPoint(x: rect.midX, y: rect.maxY)) path.addLine(to: CGPoint(x: rect.maxX * 0.75, y: rect.maxY)) path.addLine(to: CGPoint(x: rect.maxX * 0.75, y: rect.minY)) path.addLine(to: CGPoint(x: rect.midX, y: rect.minY)) path.addLine(to: CGPoint(x: rect.maxX, y: rect.minY)) } } }
struct PathAnimationExample: View { var body: some View { VStack { DevTechieShape() .stroke(Color.orange, lineWidth: 10) .frame(width: 200, height: 200) } } }
struct PathAnimationExample: View { @State private var pathProgress = 0.0 var body: some View { VStack { DevTechieShape() .trim(from: 0.0, to: pathProgress) .stroke(Color.orange, lineWidth: 10) .frame(width: 200, height: 200) Slider(value: $pathProgress, in: 0.0...1.0) .padding() } } }
struct PathAnimationExample: View { @State private var pathProgress = 0.0 var body: some View { VStack { DevTechieShape() .trim(from: 0.0, to: pathProgress) .stroke(Color.orange, lineWidth: 10) .frame(width: 200, height: 200) .animation(.easeInOut(duration: 10), value: pathProgress) Slider(value: $pathProgress, in: 0.0...1.0) .padding() } } }
With that we have reached the end of this article. Thank you once again for reading. Subscribe to our weekly newsletter at https://www.devtechie.com