This makes a nice pairing with our UIView path animation from yesterday – PRTween:
PRTween is a lightweight tweening library built for iOS. While Apple has done an incredible job with UIView Animations and Core Animation, there are sometimes cases that are difficult to get around. PRTween is a great alternative if you’d like to:
- Animate a property Core Animation won’t allow you to
- Ensure that [someView layoutSubviews] is respected during an animation
- Tween arbitrary numerical values, such as sound volume, scroll position, a counter, or many others
- Define your timing curve as a function rather than a bezier with control points
PRTween aims to be as simple as possible without sacrificing flexibility…
That second point about respecting layouts during animation is particularly interesting. We’ve had a couple instances where that kind of thing has gone off the rails with varying degrees of ensuing hilarity, indeed. Also, it’s nice to see some more complex computability:
… Sometimes you will find it necessary to animate a complex value, such as a CGPoint. Although you could write two tweens for the x and y fields, it is much simpler to use linear interpolation, or lerps … PRTween currently has built-in lerps for CGPoint and CGRect …
Looks like a pretty sweet start for adding some liveliness to your interface, yep. Also note iheart2code / PRTween for ARC-compatible fork.
(And don’t forget CPAnimationSequence for simplifying animation of stock Core Animation properties!)
h/t: ManiacDev!
JUN