views:

458

answers:

2

Hi,

I'm just starting writing some Core Animation code and I've just spent a frustrating day trying to figure out a particular problem.

I have two layer-backed views that together make up a wizard/ assistant style user interface:

1) a custom background view that fills the entire window with an edge-to-edge gradient and a nice image on the left hand side 2) a smaller framed view on the right that acts as a home for changing dialog choices as you click the "forwards"/ "backwards" buttons: labels, controls, buttons, etc.

I've "stolen" some example code that animates a lighting filter and thus produces a pulsating effect.

I've added the animation and the filter to the custom background view's CALayer. It works fine, but the controls in the smaller framed view also pulsate!

I'm at a loss to understand how that can be the case and I expect the controls to remain unaffected by the filter applied to the layer below it. Surely the CALayer associated with the smaller view should get composited on top of the background view's layer and everything on its layer should remain unaffected!?

I've played around with various scenarios and it's clear to me that I'm missing something very basic here.. please help!

+1  A: 

A CALayer's content filter affects the layer and its sublayers. From your question it sounds like the view on the right side is a subview of your background view, which effectively makes its layer a sublayer of the background's layer, and the filter will apply to it as well.

Depending on exactly what you are trying to do, you might have better luck with a background filter instead of content filter. If I understood your setup correctly, you should be able to set a background filter on the right side view instead of a content filter on the background view.

Rhult
A: 

Hi Rhult,

Yes, I've been ruminating about this over the past few hours and then had an "aha" moment. I had assumed that the filters wouldn't be "inherited" down the tree, but that's plainly not the case.

I did try the background filter route even though I didn't understand at the time why that would be any different from setting the content filter on the parent view. Of course it is because of the "inheritance".

Unfortunately my animation code snippet didn't seem to work if I set the background filter rather than the content filter, so I abandoned that probably a bit early.. I'll have another go.

Thanks very much for your help.

Best regards,

Frank

Frank
If you want to address Rhult's comments, do it in a comment to his post instead of adding a new answer to your question.
Johan Dahlin