• 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
Problems understanding CALayer geometry
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problems understanding CALayer geometry


  • Subject: Problems understanding CALayer geometry
  • From: Henri Häkkinen <email@hidden>
  • Date: Sat, 21 Nov 2009 17:21:55 +0200

Hello.

I am deriving my own custom CALayer class for my custom NSView class but there is something I don't quite understand about the geometry.

This is how I create the layer in awakeFromNib: of my custom NSView class:

- (void)awakeFromNib {
	MyLayer *myLayer = [MyLayer layer];

	self.layer = myLayer;
	self.wantsLayer = YES;

	myLayer.needsDisplayOnBoundsChange = YES;
	myLayer.position = CGPointMake(100.0, 100.0);
	myLayer.bounds = CGRectMake(0.0, 0.0, 100.0, 100.0);
}

And this is how I draw the layer in MyLayer:

- (void)drawInContext:(CGContextRef)context {
	CGContextFillRect(context, [self bounds]);
}

I don't any other methods overidden by neither of the classes.

However the layer somehow automatically gets resized to fill the whole view (that is, the view is rendered completely in black by the CGContextFillRect call). How I understand this, I think it should just draw a 100x100 rectangle at the position (100, 100). What am I missing?

Regards,
Henri Häkkinen

_______________________________________________

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

  • Prev by Date: Re: Saving data as NSData using NSUserDefaults
  • Next by Date: Re: How to change UITableView cell style dynamically
  • Previous by thread: Re: Saving data as NSData using NSUserDefaults
  • Next by thread: Re: Problems understanding CALayer geometry
  • Index(es):
    • Date
    • Thread