我正在尝试为CATextLayer的string属性设置动画,以便可以使用AV Foundation为我的视频添加时间戳。有谁知道如何制作动画,以便我每秒可以更改字符串值?

最佳答案

NSString *labelText = @"foobar";
[textLayer setString:labelText];


这必须在主线程上运行,因此我使用以下命令:

 NSString *labelText = @"foobar";
[textLayer performSelector:@selector(setString:) withObject:labelText waitUntilDone:YES];


并且,如果您要经常更新,则应在文本更改之间禁用动画:

NSString *labelText = @"foobar";
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
[textLayer performSelector:@selector(setString:) withObject:labelText waitUntilDone:YES];
[CATransaction commit];

关于iphone - 动画CATextLayer字符串属性,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8388579/

10-09 01:12