我正在尝试动画CATextLayer的字符串属性,以便我可以使用AV Foundation为我的视频添加时间戳。有谁知道如何设置动画这样我可以每秒更改字符串值??
答案 0 :(得分:2)
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];