Blinking effect on UILabel

前端 未结 14 1997
野的像风
野的像风 2020-12-13 14:24

I have a UILabel with background color as grey.

I want a blinking effect on this label like it should become a little white & then become gray and it should keep

14条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 14:53

    This is how it worked for me. I adapted the answer of @flex_elektro_deimling

    First parameter UIView.animateWithDuration is the total time of the animation (In my case I've set it to 0.5), you may set different values on the first and second (delay) to change the blinking speed.

        self.YOURLABEL.alpha = 0;
        UIView.animateWithDuration(
            0.5, 
            delay: 0.2, 
            options: UIViewAnimationOptions.Repeat | UIViewAnimationOptions.Autoreverse, animations: {
                self.YOURLABEL.alpha = 1
            },
            completion:nil)
    

提交回复
热议问题