Re: -renderInContext: with multiple layers?
Re: -renderInContext: with multiple layers?
- Subject: Re: -renderInContext: with multiple layers?
- From: Rick Mann <email@hidden>
- Date: Mon, 15 Aug 2011 15:57:03 -0700
Each of my layers is actually a layer hierarchy.
The problem I'm seeing is that if the image context's size is larger than the layer being drawn, the resulting image is smaller than it should be, even for a single layer hierarchy.
For example, let's say my layer is 100 px wide, but the image context I create is 200 px wide. I render the image, then use that image to create a UIImageView. The pixels in the resulting view are not 100 px wide, but rather 50 px (I'm guessing at the exact width, but it appears to be about that).
Drawing the second view, hopefully, is as easy as translating the CTM. It was NOT enough to set the view's frames.
--
Rick
On Aug 15, 2011, at 15:46 , Kyle Sluder wrote:
> On Mon, Aug 15, 2011 at 2:47 PM, Rick Mann <email@hidden> wrote:
>> Hi. I have two UIView hierarchies, visually side-by side, but at different parts of an overall view hierarchy. I'd like to create a single UIImage of the two, using -renderInContext: and UIGraphicsGetImageFromCurrentImageContext(). I was able to make one work alone just fine. But when I make my graphics context (using UIGraphicsBeginImageContext()) large enough to encompass both, and set each UIView's frame so that they are side-by-side, the resulting image shows just the left-cell's content, squished horizontally.
>
> Yes, but you need to set up the CTM to draw the layers in the right
> place. To be clear, you're asking the views' layers to
> -renderInContext:, not the views themselves.
>
> We use -renderInContext: to draw entire layer trees into one big
> context. You obviously aren't doing the same thing, but the principle
> is identical. You might want to look into our CALayer extension method
> for doing so: https://github.com/omnigroup/OmniGroup/blob/master/Frameworks/OmniQuartz/CALayer-OQExtensions.m#L497
>
> --Kyle Sluder
_______________________________________________
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