domhofmann / PRTween

Lightweight tween library for iOS
BSD 2-Clause "Simplified" License
459 stars 63 forks source link

Add shorthand for simple tweens #3

Closed domhofmann closed 13 years ago

domhofmann commented 13 years ago

There will be times that developers simply want to tween some value from A to B without writing a lot of code. In these cases, it seems like we should support something similar to the following.

CGFloat x = 0;
[PRTween tween:&x to:40 duration:0.3];

We could support these "overloads":

[PRTween tween:to:duration]
[PRTween tween:to:duration:timingFunction:]
[PRTween tween:to:duration:timingFunction:completionSelector]
[PRTween tween:to:duration:timingFunction:completionBlock]

We should also support non-relative tweens:

[PRTween tween:from:to:duration]
[PRTween tween:from:to:duration:timingFunction:]
[PRTween tween:from:to:duration:timingFunction:completionSelector]
[PRTween tween:from:to:duration:timingFunction:completionBlock]
domhofmann commented 13 years ago

We should use this an opportunity to make a decision regarding overloads as well. Moving forward, will we support multiple versions of our methods or would we rather have developers passing in nil and NULL?

domhofmann commented 13 years ago

I've added basic support for this in the 0.2-dev branch. For example:

[PRTween tween:testView property:@"alpha" from:1 to:0 duration:3];

You can also directly tween values. Suppose you're developing a game that has a scrollPosition CGFloat.

[PRTween tween:&scrollPosition from:0 to:20 duration:3];

domhofmann commented 13 years ago

Merged into master.