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 happen till I turn it off programatically.
Any clue how to achieve this?
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 happen till I turn it off programatically.
Any clue how to achieve this?
You can simply make an extension to the UILabel class that will support the blinking effect. I don't think using a timer is a right approach since you won't have any fade effect.
Here is the Swift way to do this:
Swift 3:
EDIT Swift 3: Works for almost any view
Rather use the view animations. It makes it very simple and is easy to control. Try this:
You can tweak the values to get different effects for example, changing animateWithDuration wil set the blinking speed. Further you can use it on anything that inherits from UIView example a button, label, custom view etc.
You can do this within a block:
So you dont need a second method.
Swift 3
My swift version based on
Flex Elektro Deimling's
answer: