Hi,
One of my views uses a CAShapeLayer to provide a line-dash. To date, I've been using the following technique to capture if there is an animation in progress in the layer's containing view and apply it to the layer also:
This works well for non-interactive animations.
However, when I try to perform an interactive animation (i.e pausing a UIViewPropertyAnimator and adjusting its fractionComplete property) the layer animation fails to pause and simply continues to its end position.
Is there a simple way to setup a view's layer hierarchy to support the interactive animation of its sublayers?
One of my views uses a CAShapeLayer to provide a line-dash. To date, I've been using the following technique to capture if there is an animation in progress in the layer's containing view and apply it to the layer also:
Code Block override func layoutSubviews() { let layerBoundsSizeAnimation = layer.animation(forKey: "bounds.size") CATransaction.begin() if let layerBoundsSizeAnimation = layerBoundsSizeAnimation { CATransaction.setAnimationDuration( layerBoundsSizeAnimation.duration) CATransaction.setAnimationTimingFunction( layerBoundsSizeAnimation.timingFunction) let pathAnimation = CABasicAnimation(keyPath: "path") borderLayer.add(pathAnimation, forKey: "path") } else { CATransaction.setDisableActions(true) } borderLayer.path = CGPath(rect: bounds, transform: nil) CATransaction.commit() }
This works well for non-interactive animations.
However, when I try to perform an interactive animation (i.e pausing a UIViewPropertyAnimator and adjusting its fractionComplete property) the layer animation fails to pause and simply continues to its end position.
Is there a simple way to setup a view's layer hierarchy to support the interactive animation of its sublayers?