For a CALayer
,
which is animating,
class Test: CAGradientLayer {
override func draw(in ctx: CGContext) {
super.draw(in: ctx)
startPoint = ....
}
*** Terminating app due to uncaught exception 'CALayerReadOnly', reason: 'attempting to modify read-only layer
It appears to be impossible to change one of the ordinary animatable properties, inside the draw#inContext
call.
So for example:
It's easy and simple to have an animatable custom property of your own, and then draw something based on that. Here's some code for a .progress
property,
https://stackoverflow.com/a/37470079/294884
while animating your .progress
property, it would be easy to imagine wanting to set other properties of the layer, using some formula based on the value of .progress
each frame.
However, you can not do it in the draw#in
function - how to do it ?