I am trying to animate CATextLayer's string property so I can put a timestamp to my video using AV Foundation. Does anyone know how to animate this so I can change the string value every second??
Asked
Active
Viewed 1,420 times
1 Answers
2
NSString *labelText = @"foobar";
[textLayer setString:labelText];
This must be run on the main thread, so I use this:
NSString *labelText = @"foobar";
[textLayer performSelector:@selector(setString:) withObject:labelText waitUntilDone:YES];
And if you are updating frequently, you should disable the animations between the text changes:
NSString *labelText = @"foobar";
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
[textLayer performSelector:@selector(setString:) withObject:labelText waitUntilDone:YES];
[CATransaction commit];

coneybeare
- 33,113
- 21
- 131
- 183
-
Thanks, but I dont think this would help. What I am trying to do is to add timestamps to videos (like survalance videos with date and time on ) and then export CATextLayer with my video to .mov file. So I don't really play the video or the CATextLayer to the screen. What I am looking for is something that can do a synchronized change to the string value in CATextLayer with my video when I do my video composition export, something like CAKeyframeAnimation which I can add to my CATextLayer (but I am not sure how to set it up or if it would solve my problem..) Thanks! – james bond Dec 05 '11 at 17:09