• 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
NSView, CALayer, setNeedsDisplay
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSView, CALayer, setNeedsDisplay


  • Subject: NSView, CALayer, setNeedsDisplay
  • From: Martin Hewitson <email@hidden>
  • Date: Sat, 12 Mar 2011 19:03:08 +0100

Dear list,

I have a layer backed view whose layer contains many sublayers. The problem is that the layer doesn't get drawn in the view when the app starts. If I resize the window, then the layer and all its sublayers draw properly. I've solved this problem before with what seemed like a magic collection of [calayer setNeedsDisplay] and [view setNeedsDisplay:YES], but this time I can't seem to get it to work. Therefore, I thought I'd ask if anyone knows the correct way to do this.

My view subclass makes its layers like this:

- (void) setupLayers
{
  NSLog(@"Setting up layers");
  CALayer *rootLayer = [CALayer layer];
  rootLayer.layoutManager = [CAConstraintLayoutManager layoutManager];
  [self setLayer:rootLayer];
  [self setWantsLayer:YES];
  yearLayer = [[CAYearLayer alloc] initWithDate:self.year dataSource:self.datasource];
  [rootLayer addSublayer:yearLayer];
  [rootLayer setNeedsDisplay];
  [self setNeedsDisplay:YES];
}

and the setupLayers is called in awakeFromNib of the view subclass.

Any hints gratefully received.

Martin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
    Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





_______________________________________________

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

  • Follow-Ups:
    • Re: NSView, CALayer, setNeedsDisplay
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Bound NSTextField
  • Next by Date: Re: NSView, CALayer, setNeedsDisplay
  • Previous by thread: Bound NSTextField
  • Next by thread: Re: NSView, CALayer, setNeedsDisplay
  • Index(es):
    • Date
    • Thread