• 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: problem getting CALayer to draw an image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem getting CALayer to draw an image


  • Subject: Re: problem getting CALayer to draw an image
  • From: Rob Petrovec <email@hidden>
  • Date: Thu, 05 Apr 2018 12:03:44 -0600

If you take out the setNeedsDisplay it draws ok.

—Rob


> On Apr 5, 2018, at 11:53 AM, James Walker <email@hidden> wrote:
>
> I have a generic NSView that contains some subviews, and I'd like to add a
> background image.  I tried code like this:
>
> NSImage* backgroundImage = [NSImage imageNamed: @"blueprint controls.png"];
> CALayer* holderLayer = [CALayer layer];
> _throttleHolder.layer = holderLayer;
> _throttleHolder.wantsLayer = YES;
> holderLayer.zPosition = 4.0f;
> holderLayer.contents = backgroundImage;
> holderLayer.hidden = NO;
> holderLayer.bounds = NSRectToCGRect( _throttleHolder.bounds );
> [holderLayer setNeedsDisplay];
>
> But no background image shows up.  On the other hand, if I add the line
>
> holderLayer.backgroundColor = CGColorGetConstantColor( kCGColorWhite );
>
> then I get a white background, so apparently the layer is there and capable
> of drawing.  And yes, I have made sure that backgroundImage is not nil.
>
> At this point, it probably would have been quicker to just go ahead and
> subclass NSView, but I'm curious about what dumb mistake I'm making.
> _______________________________________________
>
> 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

_______________________________________________

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: 
 >problem getting CALayer to draw an image (From: James Walker <email@hidden>)

  • Prev by Date: problem getting CALayer to draw an image
  • Next by Date: Re: problem getting CALayer to draw an image
  • Previous by thread: problem getting CALayer to draw an image
  • Next by thread: Re: problem getting CALayer to draw an image
  • Index(es):
    • Date
    • Thread