How do I apply an animation around a button?

前端 未结 1 1228
长情又很酷
长情又很酷 2021-01-26 15:30

I have 30 sec of a song being played when the play button is being played. I want a progress bar to go around the play button as the song is being played. How would I do this? <

相关标签:
1条回答
  • 2021-01-26 16:20

    I'm assuming you want something like this:

    It is a CAShapeLayer whose path is a circle. We start with a strokeEnd of 0 and animate it up to 1. You can poll the song's progress using an NSTimer at, say, 1-second intervals and calculate how much of the song has played, and set the strokeEnd to that fraction.

    0 讨论(0)
提交回复
热议问题