How to create a glowing effect with a UILabel?
Asked Answered
W

1

6

I'm trying to achieve something exactly like this:

enter image description here

I've found a few questions related to mine:

  1. How to set the colors in glowing effect of a UILabel?
  2. IPhone Text Glow Effect
  3. Create glowing text effect on iOS
  4. xcode UILabel text add outer glow effect

The majority of the answers suggests modifying the UILabel's layer property by adjusting its shadow, and the questions are outdated.

I've tried the suggestions using the following code:

myLabel.layer.shadowColor = UIColor.black.cgColor
myLabel.layer.shadowOffset = .zero
myLabel.layer.shadowRadius = 2.0
myLabel.layer.shadowOpacity = 1.0
myLabel.layer.masksToBounds = false
myLabel.layer.shouldRasterize = true

And got the following result:

enter image description here

The glow is not strong enough and doesn't disperse out more. I've tried playing around with offset, radius, and opacity but the glow was either the same or less distinct.

Is this still possible or is there a work-around that someone can suggest to me?

Thanks

Wicklund answered 11/1, 2018 at 7:3 Comment(2)
try changing the shadowColor to white or some other bright colorsFlagellant
This might be useful to your case.Savonarola
W
3

Change the shadow color to white:

myLabel.layer.shadowColor = UIColor.white.cgColor
Wartburg answered 8/12, 2019 at 21:6 Comment(1)
From my experience this does not work. Shadow comes out dark looking - not like Pangu's desired image.Hyades

© 2022 - 2024 — McMap. All rights reserved.