I have a stylekit in paintcode with one stylekit drawing method that takes a single parameter - is there any way I can use UIView.animateWithDuration(etc..) to animate that parameter so my view updates smoothly?
You won't do animateWithDuration because that creates the keyframes for you and that's what you're doing with the variables you pass into the draw method generated by PaintCode.
You'll want to implement a custom UIView. Create a property for the custom class that holds the variable value for the param your drawing method accepts. Overwrite drawRect
in order to call the StyleKit draw method and pass in the local variable that holds the value for the variable.
Then you'll use an NSTimer
to iterate through a values over time, updating the custom UIView's property with each iteration. The trick is that when the property is updated you'll need to call self.setNeedsDisplay
(swift) or [self setNeedsDisplay:YES];
(obj-c).
There is a great blog post on it available here: https://medium.com/a-first-project-with-paintcode/animating-the-arrow-6e61104b321b
Paintcode gives you 3 options in its FAQ section:
Some of them have better performance than the others, and you can download an example project (Swift and Objective-C) directly from their website.
Reference: https://www.paintcodeapp.com/faq/animate-drawings-made-paintcode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With