Skip to content

Instantly share code, notes, and snippets.

@iAmVishal16
Created April 4, 2023 18:49
Show Gist options
  • Select an option

  • Save iAmVishal16/9e27c6d808c521bee66246311627d130 to your computer and use it in GitHub Desktop.

Select an option

Save iAmVishal16/9e27c6d808c521bee66246311627d130 to your computer and use it in GitHub Desktop.
Triangle Shape in SwiftUI
struct Triangle: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
path.move(to: CGPoint(x: rect.midX, y: rect.minY))
path.addLine(to: CGPoint(x: rect.minX, y: rect.maxY))
path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
path.addLine(to: CGPoint(x: rect.midX, y: rect.minY))
return path
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment