【问题标题】:Round Corner of Path Line SwiftUI路径线 SwiftUI 的圆角
【发布时间】:2019-10-31 02:38:01
【问题描述】:

我怎样才能画一条末端圆润的线?我正在画一条简单的直线,如下所示,但不能把末端弄圆。 “.cornerRadius”不起作用。有什么想法吗?

struct Line: View {
    let geoProx: GeometryProxy

    var body: some View {
        Path{ path in
            path.move(to: CGPoint(x: geoProx.size.width/2, y: geoProx.size.height/2))
            path.addLine(to: CGPoint(x: geoProx.size.width/2 - geoProx.size.width/4, y: geoProx.size.height/2))

        }
        .stroke(lineWidth: 8.0)
        .foregroundColor(.white)
        .cornerRadius(10.0)
        .zIndex(1.5)
    }
}

【问题讨论】:

    标签: ios swift iphone swiftui


    【解决方案1】:

    尝试替换:

    .stroke(lineWidth: 8.0)
    

    与:

    .stroke(style: StrokeStyle(lineWidth: 8.0, lineCap: .round))
    

    【讨论】:

    • 我正在使用 swift 5,这不起作用。
    猜你喜欢
    • 1970-01-01
    • 2021-12-27
    • 2013-11-23
    • 2013-03-18
    • 2023-01-17
    • 2023-01-12
    • 2020-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多