Hi,

I was reading the code (part of Core Animation sample code) and could
not understand the part
 that the reflection layer is a sublayer of the desktop image layer.

e.g,  in Controller.m

layer = [CALayer layer];
....
desktopImageLayer = [CALayer layer];
....
....
[layer setSublayers:[NSArray arrayWithObject:desktopImageLayer]];

...

CALayer *sublayer = [CALayer layer];  // for reflection

[desktopImageLayer addSublayer:sublayer];

[sublayer addSublayer:gradientLayer];

the image ref will later to set as the content of desktopImageLayer,
and sublayer


layer
    |---------- desktopImageLayer
                           |-------------------------------sublayer

   |------------ gradientLayer


if (image != NULL)
                {
                        // main image
                        [layer setContents:(id)image];    <------  Line A
                        [layer setBackgroundColor:NULL];
                        NSArray *sublayers = layer.sublayers;
                        // reflection
                        CALayer *sublayer = (CALayer *)[sublayers 
objectAtIndex:0];
                        [sublayer setContents:(id)image];    <------------- 
Line B.
                        [sublayer setBackgroundColor:NULL];
                        CGImageRelease (image);
                }

Two questions
 1)  I would think  sublayer above should be child of layer (and
sibling of desktopImageLayer). what is the reason for the current
setup?
With this setup, is it true that a sublayer is not geometrically
constraint to be inside the bounds of its superlayer?

 2) In Line A noted above,  the content of layer is set. What is the
impact of this to its sublayers?  Later, the sublayer's content is
also set.

Thanks for any insights on this.

--
Wayne Shao
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to