struct BlurLinearGradient: View {
let image: Image
var body: some View {
ZStack {
image
.resizable()
.scaledToFill()
image
.resizable()
.scaledToFill()
.blur(radius: 20, opaque: true)
.mask {
LinearGradient(
colors: [.clear, .black],
startPoint: .center,
endPoint: .bottom
)
}
}
}
}
// Usage
struct ContentView: View {
var body: some View {
BlurLinearGradient(image: Image("f1"))
.frame(width: 280, height: 480)
.clipShape(RoundedRectangle(cornerRadius: 8))
}
}
Result: