Adds a shadow effect beneath a view with customizable color, radius, and offset.
97.2% of iOS users can use this modifier
iOS 13+ required
.shadow(color:radius:x:y:) Applies shadow with full customization
color: Colorradius: CGFloatx: CGFloaty: CGFloat.shadow(radius:) Applies shadow with default black color
radius: CGFloatAdd a simple shadow with default settings
Text("Hello, World!")
.padding()
.background(.white)
.shadow(radius: 5)Create a colored shadow with offset
RoundedRectangle(cornerRadius: 10)
.fill(.white)
.frame(width: 200, height: 100)
.shadow(color: .blue.opacity(0.3), radius: 10, x: 0, y: 5)Multiple shadows for depth effect
VStack {
Text("Card")
}
.padding()
.background(.white)
.shadow(color: .black.opacity(0.1), radius: 2, x: 0, y: 1)
.shadow(color: .black.opacity(0.15), radius: 10, x: 0, y: 5)Loading related modifiers...
The .shadow() modifier requires iOS 13 or later. This means 97.2% of current iOS users can use this modifier.
Apply the .shadow() modifier to any SwiftUI view. Check the code examples above for usage patterns.
Visit the official Apple documentation for detailed information.