On Jun 21, 2011, at 9:57 PM, Graham Cox wrote: > I'm getting confused and frustrated by Core Animation layers (again). Mac OS. > > > If I simply add a NSView to a window in IB, not subclassed, but turn on Core > Animation layer for that view and set a background colour, shouldn't it > appear with that colour in the window? That's my expectation, but that's not > what I get. Instead, I see nothing. I can log the fact that the layer exists, > and it has apparently the right dimensions and so on, but nothing is actually > displayed.
Setting a background color to the layer? The order of creation of the layer is the entire dependency here. This is discussed in the animation overview. There are to types of layer/view interactivity Layer-backed - the view uses the layer as a cache of sorts. You should leave the layers alone. Period. You just call setWantsLayer: and the view makes a layer. If you replace it, it still isn’t your’s to touch. (and you probably shouldn’t) Layer-hosted - the view hosts a layer-tree that you create. The difference is that you create a layer, do setLayer: on the view, and then turn on setWantsLayer:. If you don’t do it in that order, you should not touch the layers. it’s entirely the order of setLayer: setWantsLayer: that controls whether you should touch the layers. If you do it this order, you can, if you do setWantsLayer: first, hands off. > > Where are my assumptions faulty? > > Depends on the above. After knowing that, we can move forward. _______________________________________________ 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