Animate Custom UIView Property in Swift

后端 未结 2 1519
一向
一向 2021-01-03 07:01

all!

I have created a circular progress view using CoreGraphics that looks and updates like so:

50% 75%

The class is a UIView

2条回答
  •  一生所求
    2021-01-03 07:46

    Whilst AntonTheDev provides a great answer, his solution does not allow you to animate the CircularProgressView in an animation block, so you cant do neat things like:

    UIView.animate(withDuration: 2, delay: 0, options: .curveEaseInOut, 
    animations: {
        circularProgress.progress = 0.76
    }, completion: nil)
    

    There's a similar question here with a up to date Swift 3 answer based on ideas from the accepted answer and this post. This is what the final solution looks like.

    Swift 3 Solution

提交回复
热议问题