In this article, I will show you how to implement the shadow object using SwiftUI. I would like to use ViewModifier for my project.
struct ShadowModifier: ViewModifier { func body(content: Content) -> some View { content
.shadow(color: Color("lightShadow"), radius: 8, x: -8, y: -8)
.shadow(color: Color("darkShadow"), radius: 8, x: 8, y: 8) }}
Inner shadow
struct InnerShadowModifier: ViewModifier {@State var radius: CGFloat = 10func body(content: Content) -> some View {content.overlay(
RoundedRectangle(cornerRadius: radius)
.stroke(Color("bgColor"), lineWidth: 4)
.shadow(color: Color("darkShadow"), radius: 4, x: 5, y: 5)
.clipShape(RoundedRectangle(cornerRadius: radius))
.shadow(color: Color("lightShadow"), radius: 4, x: -5, y: -5)
.clipShape(RoundedRectangle(cornerRadius: radius))}}