Nov 22, 2021Neon style in SwiftUI
struct NeonStyle: ViewModifier {
let color: Color
func body(content: Content) -> some View {
content
.foregroundColor(color).brightness(0.3)
.shadow(color: color, radius: 10, x: 0, y: 0)
}
}
extension View {
func neon(color: Color) -> some View {
modifier(NeonStyle(color: color))
}
}
Label("Neon effect", systemImage: "bolt.fill")
.font(.system(.largeTitle, design: .rounded))
.neon(color: .yellow)
.padding()
.padding()
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(lineWidth: 4)
.neon(color: .yellow)
)