adam-siton / AUIAnimatedText

A drop-in UILabel replacement that makes almost all properties animatable by using a CATextLayer instead of CALayer.

Home Page:http://corecocoa.wordpress.com/2011/10/04/animatable-text-color-of-uilabel/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AUIAnimatableText

AUIAnimatableText is a drop-in UILabel replacement that uses CATextLayer instead of the regular CALayer, and thus making almost all the properties animatable.

Properties animatable in AUIAnimatableText and not in UILabel

  1. textColor
  2. text
  3. font
  4. fontSize

Adding AUIAnimatableText to your project

  1. Add AUIAnimatableText.h+m and UIFont+CoreTextExtensions.h+m to your project
  2. Link your project with CoreText.framework and QuartzCore.framework (In your project's settings, go to "Build Phases" and there to "Link Binary With Libraries")
  3. Change the class of your labels from UILabel to AUIAnimatableText in code or in interface builder
  4. That's it.

After doing the above steps you can simply change the label's properties inside a UIView animation block and they will change animated.

To get the duration to work properly it looks like you need to use:

[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:0.7f] forKey:kCATransactionAnimationDuration];
{...new layout code here...}
[CATransaction commit];

(I'm not sure if CATransaction supports block-style animation, this is just what I've found out so far.

About

A drop-in UILabel replacement that makes almost all properties animatable by using a CATextLayer instead of CALayer.

http://corecocoa.wordpress.com/2011/10/04/animatable-text-color-of-uilabel/

License:MIT License


Languages

Language:Objective-C 96.4%Language:Ruby 3.6%