Post

Replies

Boosts

Views

Activity

Reply to why is the view.shadow offset from the correct position.
here is a simpler demonstration of this problem : import SwiftUI struct ThisShape : Shape {     func path(in rect: CGRect) -> Path {         let a = rect.size.width/4         let b = rect.size.height/4      	 var path = Path()         path.move(to: CGPoint(x: 3*a, y: 3*b))         path.addLine(to: CGPoint(x: 3*a, y: b))         path.addLine(to: CGPoint(x: a, y: b))         path.addLine(to: CGPoint(x: a, y: 3*b))         return path     } } struct ThisThing: View {     var body: some View {         ThisShape()             .stroke(lineWidth: 2)             .aspectRatio(1, contentMode: .fit)     } } struct ThisThing_Previews: PreviewProvider {     static var previews: some View {         ThisThing()             .shadow(radius: 2,x:0,y:0)     } } the question remains, why is the shadow offset by the distance from the top right corner to the nearest point of the path? it appears that there is an inherent shadow offset equal to the distance between the origin of whatever view it is drawn in and the closest vertex to that origin. playing with the aspect ratio on line 21 will help to illustrate that.
Sep ’20