Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You're breaking a fundamental <code>CALayer</code>/<code>NSView</code> rule by creating a layer-backed view and then trying to manipulate the layer directly.</p> <pre><code>aLayer = [CALayer layer]; [theView setWantsLayer:YES]; [theView setLayer:aLayer]; </code></pre> <p>When you tell the view to use a layer before calling <code>setLayer:</code>, the view becomes "layer-backed" -- it is simply using the layer as a buffer and all drawing that you want to do should be done through the usual <code>drawRect:</code> and related methods. You are not allowed to touch the layer directly. If you change the order of those calls:</p> <pre><code>[theView setLayer:aLayer]; [theView setWantsLayer:YES]; </code></pre> <p>You now have a "layer-hosting" view, which means that the view just provides a space on the screen for the layer to be drawn into. In this case, you do your drawing directly into the layer. Since the contents of the layer become the contents of the view, you cannot add subviews or use the view's drawing mechanisms.</p> <p>This is mentioned in the <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html#//apple_ref/occ/instm/NSView/setWantsLayer:" rel="noreferrer"><code>-[NSView setWantsLayer:]</code></a> documentation; I also found an <a href="http://www.cocoabuilder.com/archive/cocoa/304625-understanding-layer-backed-views.html" rel="noreferrer">old cocoa-dev thread</a> that explains it pretty well. </p> <p>I'm not certain that this will fix your problem, but as far as I can see you're doing everything else correctly, such as setting the fill mode and updating the value after the animation finishes.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload