SwiftUI的Circle更改修剪属性可移动“圆”阴影

时间:2020-07-18 20:11:38

标签: ios swift xcode swiftui shadow

我正在尝试将阴影应用于圆。如果更改“圆”的修剪属性,则阴影会移动(出乎意料)。我希望阴影位于圆的修剪部分下方。我该怎么办?

struct ContentView: View {
    
    let trimValue: CGFloat = 0.5
    
    
    var body: some View {
        
        ZStack {
            
            Text("trimValue is \(trimValue.description)")
            
            Circle()
                .trim(from: 0, to: trimValue)
                .stroke(lineWidth: 40)
                .fill(Color.white)
                .shadow(
                    color: Color.gray.opacity(0.4),
                    radius: 30,
                    x: 14,
                    y: 14)

        }.frame(width: 300, height: 300)
    }
}

First image is how I want it to look like

0 个答案:

没有答案