Created
April 4, 2023 18:49
-
-
Save iAmVishal16/9e27c6d808c521bee66246311627d130 to your computer and use it in GitHub Desktop.
Triangle Shape in SwiftUI
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
| 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