Can you handle custom properties?
farfromrefug opened this issue · comments
I am very interested by your library. I am currently using CoconutKit but i am looking at switching library.
I want something more in the lines of Android animation system which i find stronger.
I have 2 questions about your library:
- can you handle custom properties? Let s say i have a custom layer drawing an arc, and i want to animated the arc sweep angle.
- Would it be possible to have a tween with an UIView animation block? That way we could still do easy UIview animations.
Thanks
Yes, PMTween handles custom properties. If you have an arc object, then you could use the initWithObject
method and pass in a keyPath that targets the sweep angle property. Check out the README section "Tweening an object's property".
I'm not exactly sure what you're asking for in your second question, but PMTween handles animations differently than UIView animations. I don't personally think PMTween's animations are much more difficult than setting up a UIView animation, though if all you need is to do a simple tween of a UIView property then PMTween may be overkill.
@poetmountain thanks for answering.
I first thought you were using CABasicAnimation
. I now see that you are not. And i like the fact that actually any property can be animated as does not rely on CABasicAnimation
.
The idea behind supporting UIView animation block was to use the easiness of it.
But i know see that you cant support UIView animation block as a tween (would be something like [UIViewTween initWithAnimationBlock:block];
About PMTween being overkill, it clearly won't be in my case. I want to use PMTween in my fork of the Titanium Mobile framework. The whole framework is based on applying properties to a UIView from a NSDictionary
like this:
{
width:100,
borderRadius:4,
backgroundColor:'blue'
}
And we actually use NSKeyValueCoding
just like you do to do so! Which is great.
Right now i am using a mix of UIView animation block and CABasicAnimation. Clearly CABasicAnimation can be replaced by tweens. Now i liked UIView animation block because i was simply "applying" my animation dictionary(something like { duration:300, width:100}
) in my block and everything was done. The layout was then animated correctly (we also use our own layout system).
Now if i want to replace that with tweens i have to think about it because if create multiple 2 tweens for width and height i dont want the UIView to be relayed out on each pass twice (once for width, once for height). I might have to create a custom tween to handle all layout properties.
I will look deeper into your project. Thanks a lot for answering
Right, PMTweenUnit doesn't support structs as target values. I felt that it would muddy things architecturally, but obviously would be useful and may look into that again at some point.
PMTween by default uses CADisplayLink for update ticks, so your UIView layout won't be triggered twice unless you manually force a layout update. Usually if I'm tweening multiple values in a struct like width and height, I will create PMTweenUnit instances for each and add them to a PMTweenGroup instance. That way you only need to save the one group instance (the group saves references to added tweens internally) and can control them all via one interface.
Good luck with your project!