CPoint定位SwiftUI

CPoint positioning SwiftUI

我正在用路径画一条线,在那条线上我想有一个圆如果我玩的话我当然可以在线上得到圆。但是我不明白为什么这段代码没有把圆圈放在线上:

struct CircleOnLineView: View {
    func createCirle() -> some View {
        return Circle().fill(Color.blue)
    }

    var body: some View {
        GeometryReader { geometry in
            ZStack {

                Path { path in
                    path.move(to: CGPoint(x: 0, y: geometry.size.height / 2))
                    path.addLine(to: CGPoint(x: geometry.size.width, y: geometry.size.height / 2))
                    }
                .stroke(Color.gray, lineWidth: 3)
                Circle()
                    .fill(Color.blue)
                    .position(CGPoint(x: 0 , y: geometry.size.height / 2))
                .frame(width: 5, height: 5)

            }
        }

    }
}

在这种情况下修饰符的顺序很重要。这是预期的方式(第一个 - 制作形状的大小,第二个 - 放置它):

Circle()
    .fill(Color.blue)
    .frame(width: 5, height: 5)
    .position(CGPoint(x: 0 , y: geometry.size.height / 2))