Animating shadow path using UIViewPropertyAnimator

I'm trying to animate a layer's shadowPath property using UIViewPropertyAnimator but it looks like it's getting instantaneously set (instead of animating or being able to set the fraction complete on the animation.)

Is there an alternative way to do this?

view.layer.shadowPath = UIBezierPath(roundedRect: .init(origin: .zero, size: .init(width: 100, height: 100)), cornerRadius: 12).cgPath

let animator = UIViewPropertyAnimator(duration: 2.0, curve: .easeInOut) {
  view.layer.shadowPath = UIBezierPath(roundedRect: .init(origin: .zero, size: .init(width: 200, height: 200)), cornerRadius: 12).cgPath
}
animator.scrubsLinearly = false
animator.pauseAnimation()
animator.fractionComplete = 0

Accepted Reply

You can use CAAnimation directly if you want to animate the shadow path. If you want to be able to animate this property with UIKit APIs, please file a feedback report!

  • Would we be able to get scrubbing behavior (i.e. setting an arbitrary fractionComplete) with CAAnimation?

Add a Comment

Replies

You can use CAAnimation directly if you want to animate the shadow path. If you want to be able to animate this property with UIKit APIs, please file a feedback report!

  • Would we be able to get scrubbing behavior (i.e. setting an arbitrary fractionComplete) with CAAnimation?

Add a Comment