如何使用UILabel创建发光效果?

时间:2018-01-11 07:03:56

标签: ios swift animation uilabel

我正在努力实现这样的事情:

enter image description here

我发现了一些与我有关的问题:

  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
  5. 大多数答案建议通过调整其阴影来修改UILabel's 图层属性,问题已过时。

    我使用以下代码尝试了这些建议:

    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
    

    得到以下结果:

    enter image description here

    发光不够强,并且不会分散得更多。我尝试过使用偏移,半径和不透明度但是发光相同或不太明显。

    这仍然是可能的还是有人可以向我建议的解决方法?

    由于

1 个答案:

答案 0 :(得分:1)

将阴影颜色更改为白色:

myLabel.layer.shadowColor = UIColor.white.cgColor
相关问题