3

Is is possible to animate the string property of a CATextLayer so that the layer will display "foo", and then "bar" after an interval?

EDIT: I need to use Core Animation because I'm trying to animate this layer in an AVMutableVideoComposition. I can get a text string to be overlaid on a video but I'd like to make it change on an interval.

Thanks.

Orpheus Mercury
  • 1,617
  • 2
  • 15
  • 30
  • By animate, do you mean it will just change from one to another? Can you just set a repeating NSTimer to call a change function and swap it back and forth. – Bergasms Dec 14 '12 at 03:33
  • Isnt this animating? `[textLayer performSelector:@selector(setString:) withObject:@"foo" waitUntilDone:YES];` Use it with a timer. – iDev Dec 14 '12 at 03:34

1 Answers1

3

You can try something like this,

[NSTimer scheduledTimerWithTimeInterval:2.0 target:self 
                               selector:@selector(changeText) userInfo:nil repeats:YES];

- (void)changeText {
     if (!isFoo) {
       [textLayer setString:@"foo"];
       isFoo = YES;
     } else {
       [textLayer setString:@"bar"];
       isFoo = NO;
     }
}
iDev
  • 23,310
  • 7
  • 60
  • 85