Re: Accessing CALayer properties
Re: Accessing CALayer properties
- Subject: Re: Accessing CALayer properties
- From: Scott Anguish <email@hidden>
- Date: Sun, 28 Oct 2007 18:08:25 -0400
On Oct 28, 2007, at 1:19 PM, Jesus De Meyer wrote:
Now that I have that out of the way. To draw an image to the layer,
do I just need to create a CGImageRef (either from a
CGImageSourceRef) and then add that image to the layer's contents
property?
Well, you could look at the doc...
Because I did that and the image didn't draw.
I'm guessing it's because of either how you're setting up the view, or
that the view is still being drawn.
BTW, I'm drawing to a CustomView and I've set the CA properties in
IB (wantsLayer and stuff)
You're setting up the View to create the layer for your.
There are two methods of integrating CA and Views.
Layer-hosting views are views where you
- create a new layer instance,
- set it as the layer of the view
- pass YES to the view method setWantsLayer:
In this case you are responsible for providing the layer content,
either by setting the contents property, or by implementing one of the
layer delegate methods.
Layer-backed views are views where you
- create the view
- pass YES to setWantsLayer:
- the view automatically creates the layer for you
This is essentially what IB does.
Layer-backed views should use the normal view drawing methods.
Typically you should leave the layer alone.
So you need to create the view, but not set wants layer in IB, do it
when the nib is loaded. also, I'm guessing in this case that the
existing screensaver might implement the drawRect: method, and so it
is wiping the content.
The other day I posted a quick example here that uses CATransitions.
it loads and displays an image using layers, and should be easy to
pull apart to get that info.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden