Is there a way to animate Paintcode variables?

I have a stylekit in paintcode with one style drawing method that takes one parameter - is there a way to use UIView.animateWithDuration (etc.) to animate this parameter so that my view updates smoothly?

+6
source share
3 answers

You will not do animateWithDuration because it creates key frames for you and what you do with the variables that you pass to the draw method generated by PaintCode.

You want to implement a custom UIView. Create a property for a custom class that contains the variable value for the parameter that your drawing method accepts. Overwrite drawRect to call the DrawKit draw method and pass in a local variable that contains the value for the variable.

You will then use NSTimer to iterate over time, updating the custom UIView property with each iteration. The trick is that when the property is updated, you need to call self.setNeedsDisplay (swift) or [self setNeedsDisplay:YES]; (obj-c).

There is a wonderful blog entry here: https://medium.com/a-first-project-with-paintcode/animating-the-arrow-6e61104b321b

+6
source

Paintcode gives you 3 options in the FAQ section:

  • Animation with UIView and NSTimer
  • Animation with CALayer Custom Animation Property
  • Animation with a custom animation property and a CALayer delegate

Some of them have better performance than others, and you can download a sample project (Swift and Objective-C) directly from your website.

Link: https://www.paintcodeapp.com/faq/animate-drawings-made-paintcode

+1
source

I ended up using the PRTween project to animate my PaintCode project. You can read about it here .

0
source

Source: https://habr.com/ru/post/989108/


All Articles