Re: CALayers - printing and flippedness
Re: CALayers - printing and flippedness
- Subject: Re: CALayers - printing and flippedness
- From: Scott Anguish <email@hidden>
- Date: Tue, 14 Sep 2010 02:33:23 -0400
On Sep 13, 2010, at 8:31 PM, Gideon King wrote:
> HI, I'm just getting started with some core animation work, and have run into a couple of issues pretty much straight away.
>
> The first is that I am trying to make sure that I will be able to print what I have on my view, but this doesn't seem to be working. I tried creating a layer backed view, which in its drawRect: method fills the rect with red, and added a sub-layer that has an image drawn on it, and an opacity on that layer of 0.5. It draws my image over the red background, but when I try to print the view, it just prints the drawing that happened in the view itself and not the sub-layer.
Layer backed views should not have their layer’s messed with. You don’t own the layer, the view does.
>
> I then tried adding a subview with the image on it, and using the layer opacity setting for the layer backing of the subview, and it looked OK on screen, but printing it showed the image at full opacity.
again, messing with the layer settings of a layer backed view. Set the opacity of the image you’re drawing. Don’t mess with a layer that isn’t yours.
>
> Is there some trick I need to know to be able to print exactly what I see on the screen?
>
> The second part of this is that I am a little confused by the documentation's statements about layer coordinate system. I want to be able to write the drawing code once and deploy both on Mac and maybe iOS later. The documentation says that UIView uses a flipped coordinate system and that therefore the root layer also has a flipped coordinate system. I tried making my view flipped, but its layer doesn't appear to be flipped. Does this mean that I have to apply a flipping transform to the root layer?
>
> It also says that layers you instantiate on iOS are flipped and on Mac are not, so I presume this means that for every layer I instantiate on MacOS, I have to apply a flip transform to get it to the state where I can use the same drawing for both platforms, right? (I am so used to drawing in flipped views, that that is the way I would want to work anyway).
Yeah, this is a confusing issue.
UIView’s have a coordinate origin at the top, NSView’s at the bottom. Any default layer you make on iOS will have the the same origin, and same on OS X.
It’s hard to tell why you’re using layer’s in this case rather than strictly the views though.
_______________________________________________
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