views:

47

answers:

1

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];
A: 

This did the trick for me:

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