How to apply animation around a button?

I have 30 seconds of a song playing when the play button is playing. I want the progress bar to appear on the play button when a song is playing. How can I do it?

play = add[indexPath.row] let playButton : UIButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton playButton.tag = indexPath.row let imageret = "playbutton" playButton.setImage(UIImage(named: imageret), forState: .Normal) playButton.frame = CGRectMake(236, 20, 100, 100) playButton.addTarget(self,action: "playit:", forControlEvents: UIControlEvents.TouchUpInside) 
-one
ios swift
source share
1 answer

I assume you want something like this:

enter image description here

This is CAShapeLayer, whose path is a circle. Let's start with strokeEnd 0 and strokeEnd it to 1. You can poll the progress of a song using NSTimer at, say, 1 second intervals, and calculate how many songs have been played, and set strokeEnd to this fraction.

+6
source share

All Articles