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
Answered by Frameworks Engineer in 708313022

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!

Accepted Answer

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!

Animating shadow path using UIViewPropertyAnimator
 
 
Q