Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw arrows in swiftUI

Tags:

swiftui

I'm trying to draw an arrow like the one below but haven't finished it yet. Hope you can help me

My code

struct ContentView: View {

    @State private var change = false
    
    private let arrowWidth: CGFloat = 128
    
    var body: some View {
        Path { path in
            path.move(to: .zero)
            path.addLine(to: CGPoint(x: arrowWidth/2, y: -20))
            path.move(to: CGPoint(x: arrowWidth/2, y:  -20))
            path.addLine(to: CGPoint(x: arrowWidth, y: 0))
        }
        .stroke(style: StrokeStyle(lineWidth: 1, lineCap: .round))
        .frame(width: arrowWidth)
        .foregroundColor(.green)
        .animation(.default)
        .padding(.top, 300)
    }
}
like image 599
David Avatar asked Jan 31 '26 07:01

David


1 Answers

enter image description here

Follow this images to create your path, then fill it

like image 142
Quang Hà Avatar answered Feb 03 '26 10:02

Quang Hà



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!