IPhone Text Glow Effect

前端 未结 6 2144
借酒劲吻你
借酒劲吻你 2020-11-30 03:22

In my IPhone application, I want the text in UILabel to glow for a second, then fade for a sec;. Also i want to repeat this cycle for say 3 or 4 times.

Is this poss

6条回答
  •  隐瞒了意图╮
    2020-11-30 04:12

    For those of you using Swift 4, here's what I used for multiple objects to Glow the same color as they are:

    let colorRed: UIColor? = timeLabel.textColor
    timeLabel.layer.shadowColor = colorRed?.cgColor
    timeLabel.layer.shadowRadius = 4.0
    timeLabel.layer.shadowOpacity = 0.9
    timeLabel.layer.shadowOffset = CGSize.zero
    timeLabel.layer.masksToBounds = false
    

    As for animating the glow, just add a timer for 3-4 loops and change .shadowOpacity to something lower.

提交回复
热议问题