Graphics Reference
In-Depth Information
transform = CATransform3DTranslate (transform, 0 , - 200 , 0 );
replicator. instanceTransform = transform;
//apply a color shift for each instance
replicator. instanceBlueOffset = - 0.1 ;
replicator. instanceGreenOffset = - 0.1 ;
//create a sublayer and place it inside the replicator
CALayer *layer = [ CALayer layer ];
layer. frame = CGRectMake ( 100.0f , 100.0f , 100.0f , 100.0f );
layer. backgroundColor = [ UIColor whiteColor ]. CGColor ;
[replicator addSublayer :layer];
}
@end
Figure 6.8 A ring of layers, created using CAReplicatorLayer
Note how the color of the layers changes as they are repeated: This was achieved using the
instanceBlueOffset and instanceGreenOffset properties. By decreasing the
intensity of the blue and green color components for each repetition, we've caused the
layers to color-shift toward red.
This replication effect may look cool, but what are the practical applications?
CAReplicatorLayer is useful for special effects such as drawing a contrail behind a
missile in a game, or a particle explosion (although iOS 5 introduced CAEmitterLayer ,
Search WWH ::




Custom Search