[SOLVED] CALayer “floating” within NSScrollView?


This Content is from Stack Overflow. Question asked by jeanlain

I’d like to have a CALayer “float” over my scroll view’s documentView. That is, it shouldn’t move during scrolling.

If I add a CALayer to my NSSCrollView‘s layer, the added layer is masked by the clipview: in only shows where the scrollers are.
Adding the layer to the clipview doesn’t work either. It’s masked.

I could add the layer to the document view and compensate the scrolling so that it stays in place, but that would be inelegant.


As it turns out, the solution was simple.

The layer was masked by the scrollview’s subviews (namely, its contentView). I simply changed the layer zPosition property to a positive value, and the layer now shows.

This Question was asked in StackOverflow by jeanlain and Answered by jeanlain It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?