I have added the Glow colour to text with the help of shadow using custom class code below in SwiftUI.
Want to achieve:-
Output:-
Code:-
struct ContentView: View {
var body: some View {
ZStack {
Text("Hello world!")
.underline()
.font(Font.system(size: 26))
.padding(.bottom, 80).shadow(color: Color(UIColor(displayP3Red: 96/255, green: 252/255, blue: 255/255, alpha: 2)), radius: 3, x: 1, y: 1)
}
}
}
Question: Can someone please explain to me how to set same glow colour on text, I've tried with above code but no results yet.
Can someone please explain to me How to get Progress?
Any help would be greatly appreciated.
Thanks in advance.
Try this:-
struct CustomLabelModify: View {
var body: some View {
ZStack{
Color.black
Group{
Text("Following")
.addGlowEffect(color1: Color(Color.RGBColorSpace.sRGB, red: 96/255, green: 252/255, blue: 255/255, opacity: 1), color2: Color(Color.RGBColorSpace.sRGB, red: 44/255, green: 158/255, blue: 238/255, opacity: 1), color3: Color(Color.RGBColorSpace.sRGB, red: 0/255, green: 129/255, blue: 255/255, opacity: 1))
}
}
}
}
extension View {
func addGlowEffect(color1:Color, color2:Color, color3:Color) -> some View {
self
.foregroundColor(Color(hue: 0.5, saturation: 0.8, brightness: 1))
.background {
self
.foregroundColor(color1).blur(radius: 0).brightness(0.8)
}
.background {
self
.foregroundColor(color2).blur(radius: 4).brightness(0.35)
}
.background {
self
.foregroundColor(color3).blur(radius: 2).brightness(0.35)
}
.background {
self
.foregroundColor(color3).blur(radius: 12).brightness(0.35)
}
}
}