Code: Select all
struct BorderBlur: ViewModifier {
var fillColor: some ShapeStyle {
AngularGradient(
colors: [.blue, .purple, .green, .blue],
center: .center)
}
var myShape : some Shape {
RoundedRectangle(cornerRadius:36)
}
let borderWidth = 3.0
let blurRadius = 5.0
public func body(content: Content) -> some View {
content
.overlay(
myShape
.stroke(lineWidth: borderWidth)
.fill(fillColor)
.padding(borderWidth)
)
.overlay(
myShape
.stroke(lineWidth: borderWidth)
.fill(fillColor)
.blur(radius: blurRadius)
.padding(borderWidth)
)
.overlay(
myShape
.stroke(lineWidth: borderWidth)
.fill(fillColor)
.blur(radius: blurRadius / 2)
.padding(borderWidth)
)
}
}
extension View {
public func borderBlur() -> some View {
return modifier(BorderBlur())
}
}