This line appears in Apple's Core Animation docs (link: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CoreAnimation_guide/SettingUpLayerObjects/SettingUpLayerObjects.html#//apple_ref/doc/uid/TP40004514-CH13-SW5)
It is recommended that you enable layer support in the content view
of your window whenever possible.
My question is: When can I NOT do that safely?
I've got a few buttons in my UI that I want to animate (rotate) using Core Animation. To do that, they need to be layer-backed. Right now, I've got just the buttons layer-backed and the rest of my views are not. This is working fine. However, Apple does not elaborate on the sentence above, so I'm worried that the animations may break in future releases because the parent views are not layer-backed.
There are two reasons I do not want to layer-back my entire view hierarchy:
So, is it safe to enable layer-backing for just a few buttons here and there and NOT enable it for the whole view hierarchy, or am I flirting with disaster? Thanks!
Yes, it's fine. I've seen previous docs from Apple that tell you to be sparing in enabling layer backing on your views, for the exact reasons you list.
The whole quote is:
In your nib files, use the View Effects inspector to enable layer support for your views. The inspector displays checkboxes for the selected view and its subviews. It is recommended that you enable layer support in the content view of your window whenever possible.
Does that mean that for any given view, when you bring up the view effects inspector, you get checkboxes for the current view AND all it's subviews? If so, Maybe the docs just mean that you should go to the window's content view and check the layer backing checkbox for each view that needs it there, rather than in the settings for the subviews.
I work mostly with iOS these days, and generally just create an outlet and call setWantsLayer: if I want to animate a Mac OS view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With