📜  UILabel 上的闪烁效果 - Swift 代码示例

📅  最后修改于: 2022-03-11 15:01:03.179000             🧑  作者: Mango

代码示例1
extension UILabel {

    func startBlink() {
        UIView.animate(withDuration: 0.8,
              delay:0.0,
              options:[.allowUserInteraction, .curveEaseInOut, .autoreverse, .repeat],
              animations: { self.alpha = 0 }, 
              completion: nil)
    }

    func stopBlink() {
        layer.removeAllAnimations()
        alpha = 1
    }
}

//Useage e.g. 
loginButton.blink(duration: 1, delay: 0.1, alpha: 0.0100000003)