JPSDisplayLink 0.0.1

JPSDisplayLink 0.0.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total111
Week0
Month0

Installs

Apps8
Test Targets1
powered by Segment

GitHub

Stars23
Watchers1
Forks5
Issues0
Contributors2
Pull Requests0

Code

Files2
LOCLines of Code 30


  • By
  • JP Simard

JPSDisplayLink provides an easy, block interface to CADisplayLink-based animations.

This is ideal for animating properties that don't support UIView-based animations like font size on a UILabel or UITextView.

Installation

Manually

Important note if your project doesn't use ARC: you must add the -fobjc-arc compiler flag to JPSDisplayLink.m in Target Settings > Build Phases > Compile Sources.

Drag the JPSDisplayLink/JPSDisplayLink folder into your project.

Usage

JPSDisplayLink only has one class method:

typedef void (^JPSDisplayLinkBlock)(CGFloat progress);

+ (void)runDisplayLinkBlock:(JPSDisplayLinkBlock)block duration:(CFTimeInterval)duration;

A JPSDisplayLink object will be created and implicitly retained for the duration specified, then it is automatically released.

Make sure you follow proper block etiquette when using JPSDisplayLinkBlock: for example, avoid retain cycles.

Easing

Add easing to your JPSDisplayLink animations by manipulating the progress parameter in your animation block.

For example, to animate a font size with cubic ease in/out, add AHEasing to your project and use the following code:

[JPSDisplayLink runDisplayLinkBlock:^(CGFloat progress) {
    CGFloat easedProgress = CubicEaseInOut(progress);
    weakLabel.font = [UIFont boldSystemFontOfSize:12.0f + easedProgress*16.0f];
} duration:5.0f];

Demo

See sample Xcode project in /JPSDisplayLinkDemo.

Here's a GIF of the demo app in action. Note that the GIF's framerate is much slower than in reality.

Demo GIF

License

This project is under the MIT license.