开发者

How to reduce the duration of an implicit animation to 0 for a CAReplicatorLayer

I've got a CAReplicatorLayer replicating its sublayer as per expected, but there's a built-in duration to the animation that I want to turn off. In other words I want to see the instantaneous results of replicating the base layer, rather than over the time duration that's implicitly specified by Apple.

Here's the replication code, bracketed by a [CATransaction ...] wrapper that I think should work but doesn't. Replication still takes a small but finite (+/- 0.25 sec) amount of time.

[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:0.0f] 
                   forKey:kCATransactionAnimationDuration];
[CATransaction setAnimationDuration:0.0];

replicator.instanceCount = 10;
replicator.instanceRedOffset = 0.1;
replicator.instanceTransform = CATransform3DMakeTranslation(x, y, 0);

[CATransaction commit];

Any thoughts? TIA Howard

I did a more extensive search and came up with the following, which unfortunately still doesn't work.

NSMutableDictionary* replicatorActions = [[NSMutableDictionary alloc]
                                            initWithObjectsAndKeys:         
                                            [NSNull null], @"instanceRedOffset",
                  开发者_如何学编程                          [NSNull null], @"instanceTransform",
                                            nil];
replicator.actions = replicatorActions;
[replicatorActions release];


This did the trick for me:

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
replicatorLayer.instanceCount += 4;
[CATransaction commit];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜