• 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: resizing window containing NSView with CALayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: resizing window containing NSView with CALayer


  • Subject: Re: resizing window containing NSView with CALayer
  • From: Graham Cox <email@hidden>
  • Date: Sun, 07 Aug 2011 11:31:59 +1000

I think you need to set the resizing mask for the layer as well - since you're creating this yourself, it's your responsibility:

zCALayerRoot.autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;

If you want the layer to redraw its content when it resizes, you also have to set:

zCALayerRoot.needsDisplayOnBoundsChange = YES;

but that's not necessary for the background host layer unless it has content other than its background colour to draw.

--Graham




On 07/08/2011, at 1:33 AM, julius wrote:

> Hi,
> is this a system error or I'm doing something wrong?
>
> In IB place a custom NSView onto a NSWindow and make sure there is a good sized border between the view and the edges of the window.
>
> In the size pane of the inspector set all the struts and springs so the view will resize with the window.
>
> This is my drawing code inside the application delegate.
> myViewObj is an IBOutlet to the custom view which contains no code other than the standard initWithFrame and drawRect templates.
>
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
> 	CALayer * zCALayerRoot = [CALayer layer];
> 	[self.myViewObj setLayer: zCALayerRoot];
> 	[self.myViewObj setWantsLayer:YES];
>
> 	self.myViewObj.layer.backgroundColor = CGColorCreateGenericRGB(0.0,0.0,0.0,1.0);
> }
>
> When we risize the window by dragging on the resize handle everything works as expected
> unless we
> 1. resize upwards until the view's rectangle disappears.
> When the window is resized the top of the view will have moved upwards but the lower border is unaffected.
>
> 2. resize by moving the rightmost edge  of the window to the right until the view disappears.
> When the window is resized the right hand side of the view will have moved to the right.
> Again the left border is unaffected.

_______________________________________________

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: resizing window containing NSView with CALayer
      • From: julius <email@hidden>
    • Re: resizing window containing NSView with CALayer
      • From: julius <email@hidden>
References: 
 >resizing window containing NSView with CALayer (From: julius <email@hidden>)

  • Prev by Date: Re: NSImageView vs IKImageView
  • Next by Date: Re: Xcode 4 core data mapping model not creating inherited attributes/relationships
  • Previous by thread: resizing window containing NSView with CALayer
  • Next by thread: Re: resizing window containing NSView with CALayer
  • Index(es):
    • Date
    • Thread