Hi David,

This sounds somewhat close to what I have already. My layer hierarchy is:


                Root
                     |
    -------------------------
    |                |               |
Rep1        Rep2       Rep3
    |                |               |
--------     --------           |
|         |     |         |          |
L1   L2   R1    R2     Text


Where L1, L2, R1 and R2 are custom CALayer subclasses that draw the coloured 
bars, and Rep 1..3 are the replicator layers that provide the reflective 
effect. (Sidenote: I'm pretty sure it's not possible to create the reflection 
effect I want using a single rep layer, as each one is set to a different 
perspective transform).

The 3 replicator layers are siblings, where Rep3 which hosts the text is added 
last and should therefore draw last, i.e. on top. (I've tested this assumption 
by trying to move it elsewhere in the sublayers list using 
-insertSublayer:atIndex: but this doesn't appear to change anything.

I also found that the text is not just being overwritten by the replicator 
layer's drawing - if I set its position to overlap the actual content (L1, R1, 
etc) it is also drawn over by the main content, so it does seem to simply  be 
in the wrong place in the drawing order.

One strange thing was that for a while, it started to work correctly, without 
me doing anything, then some cycles of dev and debugging later elsewhere in the 
code, reverted to this behaviour. The code I was working on was nothing to do 
with the graphical layers at all. This suggests that maybe there's something a 
bit random going on in establishing which layer gets to draw when.



--Graham



On 26/07/2011, at 3:18 AM, David Duncan wrote:

> On Jul 24, 2011, at 9:46 PM, Graham Cox wrote:
> 
>> I'm having a problem establishing the right Z-ordering of Core Animation 
>> layers in a view. I've tried carefully controlling the stacking order of the 
>> view's sublayers, and I've also tried setting the zPosition property, but 
>> the problem I'm having remains.
>> 
>> Here's a screen shot: http://apptree.net/images/salayer_problem.png
>> 
>> The view's hosting layer contains 3 layers, all of which are 
>> CAReplicatorLayers, to provide the reflection effect. The left and right 
>> 'bargraph' layers are supposed to be behind the 'title' layer. As you can 
>> see, the one on the left is behind, but the one on the right draws the 
>> reflection in front of the text. Nothing I do seems to make any difference 
>> to the front-to-back ordering of the layers - naturally I want the text in 
>> front of all.
>> 
>> I thought perhaps it's due to how reflections are calculated, but if that 
>> were the case the reflection on the left would draw over the text as well.
>> 
>> Each of these three layers are directly set as sublayers of the view's 
>> hosting layer, and in turn the three have further sublayers to define and 
>> draw their content.
>> 
>> I'm pretty new to Core Animation, and this is the first time I've used 
>> CAReplicatorLayer. Does anyone have some idea what's going on here?
> 
> 
> Without seeing exactly how you are laying out your layers, my recommendation 
> would be to add more layers :). To your root layer, add the replicator layer 
> and the text layer, and then add the rest of your content to the replicator 
> as you already do. By having the text layer order after the replicator layer, 
> it should draw on top of it and you should get what you are looking for.
> --
> David Duncan
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to