Clicky

iOS Dev Nugget 185 Disabling Content Change Animation in CATextLayer

.

Need to run a code review on your codebase? Hire me

Short one this week!

When using CATextLayer, it's common to change both the frame/bounds as well as the string property. You might find that even if you precede it with:

[CATransaction setValue:kCFBooleanTrue forKey:kCATransactionDisableActions];

the built-in animation still kicks in and animates the content change in an odd manner (since the bounds has also changed). What you need, to disable that is:

textLayer.actions = @{@"contents":  [NSNull null]};

There are various keys you can use to disable built-in animations such as kCAOnOrderIn and kCAOnOrderOut.


Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No

.

.

Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter

.

View archives of past issues