0

my question is quite straight forward. I am aiming to add a basic glow effect to a button in swift. I want the text to glow, not the entire button box. I have attached an image as an example to illustrate what I am aiming to achieve.Image in Agency FB font with a yellow glow effect.

I have looked elsewhere but typically only find animations which is not what I want. Sorry the image is of poor quality.

I am currently using this code but my settings button appears with a very weak glow, how can I make it stronger:

import UIKit

extension UIView {
    enum GlowEffect: Float {
        case small = 0.4, normal = 2, big = 30
    }

    func doGlowAnimation(withColor color: UIColor, withEffect effect: GlowEffect = .normal) {
        layer.masksToBounds = false
        layer.shadowColor = color.cgColor
        layer.shadowRadius = 0
        layer.shadowOpacity = 1
        layer.shadowOffset = .zero

        let glowAnimation = CABasicAnimation(keyPath: "shadowRadius")
        glowAnimation.fromValue = 20 // effect.rawValue
        glowAnimation.toValue = 20
        glowAnimation.fillMode = .removed
        glowAnimation.repeatCount = .infinity
        layer.add(glowAnimation, forKey: "shadowGlowingAnimation")
    }
}

Changing the intensity doesn't give that strong color effect near the individual letters

  • check here https://stackoverflow.com/questions/11556208/adding-glow-effect-to-uibutton-ios – Chris Dec 03 '19 at 19:03
  • I saw this link earlier too and it is useful but it is an animation. I am aiming to add an effect like shadow but in order to make the word glow. Could you possibly give some example code to show how I would achieve what is in the above image? – Hasnaine Shafiq Dec 03 '19 at 19:20
  • If it is an animation you just need to take the „end state“ of the animation and you have the effect. – Chris Dec 04 '19 at 05:58

0 Answers0