• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
question on layer setup in Covertflow sample code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

question on layer setup in Covertflow sample code


  • Subject: question on layer setup in Covertflow sample code
  • From: "Wayne Shao" <email@hidden>
  • Date: Tue, 17 Jun 2008 08:27:51 -0700

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@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: question on layer setup in Covertflow sample code
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Re: clickable NSImageView
  • Next by Date: Re: Newbie interface questions - multiple "modal" windows
  • Previous by thread: Re: clickable NSImageView
  • Next by thread: Re: question on layer setup in Covertflow sample code
  • Index(es):
    • Date
    • Thread