Re: CALayer resizing puzzle
Re: CALayer resizing puzzle
- Subject: Re: CALayer resizing puzzle
- From: David Duncan <email@hidden>
- Date: Fri, 22 Jan 2010 10:41:16 -0800
On Jan 22, 2010, at 10:18 AM, vincent habchi wrote:
> Thanks for that answer. I would dare a further request for enlightenment ;) Does it mean that:
>
> 1. by defining a suitable ContentsRect, I can get a clipped area of a CALayer just by accessing layer.contents?
> 2. that I can copy this clipped area into an area the same size on another layer defined by another ContentsRect?
>
> More specifically, if I do that:
>
> layer1.contentsRect = CGRectMake(100, 100, 50, 50);
> layer2.contentsRect = CGRectMake(0, 0, 50, 50);
> layer2.contents = layer1.contents;
>
> does it copy the bitmap contained in layer1 rectangle (100, 100, 50, 50) into layer2 rectangle (0, 0, 50, 50)?
This will set layer1 and layer2 to use the same contents, and have them use different parts of that bitmap.
However your contentsRect is being set incorrectly. The contentsRect is a rectangle in a unit coordinate system, which means that the coordinates range from 0 to 1. Assuming your contents are 200x200, then the proper contentsRects would be CGRectMake(0.5, 0.5, 0.25, 0.25) and CGRectMake(0.0, 0.0, 0.25, 0.25).
--
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