Assume I have a View
with an Image
that has a shadow
property:
struct ContentView: View {
var body: some View {
let myImage = Image("turtlerock").shadow(radius: 10)
return myImage
}
}
Now imagine I want to access the value of the shadow radius. I assumed I could do this:
print(myImage.shadow.radius)
However, this returns an error:
Value of type '(Color, Length, Length, Length) -> _ModifiedContent<_ModifiedContent, _ShadowEffect>' (aka '(Color, CGFloat, CGFloat, CGFloat) -> _ModifiedContent<_ModifiedContent, _ShadowEffect>') has no member 'radius'
Is there a way to access the modifier?
The return type of
myImage
is:We can access the original image by doing:
We can access the shadow effect modifier by typing:
So to do what you want, you have to type: