• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Putting an image on a CALayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Putting an image on a CALayer


  • Subject: Re: Putting an image on a CALayer
  • From: David Duncan <email@hidden>
  • Date: Wed, 22 Oct 2008 10:35:43 -0700

On Oct 22, 2008, at 12:09 AM, Patrick Mau wrote:

On 22.10.2008, at 02:54, DKJ wrote:

Me again. I've been using this code:

NSURL *url = [NSURL fileURLWithPath:fname];
CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)url, NULL);
CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
CFRelease(source);

theView.layer.contents = (id)image;


It compiles without complaint, but I'm still not seeing the image. I can see the effects of changing other properties of the layer (e.g. borderWidth). I've checked that image is not NULL. What am I missing here?

You are probably missing a '[theView.layer setNeedsDisplay];'

By default this will obliterate the contents that you have just set. Calling -setNeedsDisplay or -display will cause the layer to generate content and set the contents property to the result of that operation. If you set the contents property manually, you should never call - setNeedsDisplay or -display on that layer or the content you set will be lost. You can avoid this by implementing some delegate methods or subclassing a CALayer, but it is generally easier to avoid the issue entirely by maintaining control over the CALayer when doing this.
--
David Duncan
Apple DTS Animation and Printing


_______________________________________________

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


References: 
 >Putting an image on a CALayer (From: DKJ <email@hidden>)
 >Re: Putting an image on a CALayer (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Putting an image on a CALayer (From: David Duncan <email@hidden>)
 >Re: Putting an image on a CALayer (From: DKJ <email@hidden>)
 >Re: Putting an image on a CALayer (From: DKJ <email@hidden>)
 >Re: Putting an image on a CALayer (From: Patrick Mau <email@hidden>)

  • Prev by Date: Re: Yet another CALayer puzzle
  • Next by Date: WebView: Open new windows in default browser
  • Previous by thread: Re: Putting an image on a CALayer
  • Next by thread: Re: Putting an image on a CALayer
  • Index(es):
    • Date
    • Thread