views:

35

answers:

1

Hi gang,

I am wondering if there is a way to translate the underlying matrix of a layer much like you can in ActionScript3.

In AS3 I can get the transform of a layer and shift it to, let's say, make the center of the layer the anchor point, rather than the upper-left corner.

The reason I ask is because I am trying to rotate a layer (containing a square) along a diagonal axis. I thought it might be easy if I could rotate the matrix by 45 degrees, then I could just rotate around the X-axis and be done.

But I cannot figure out how to do that.

Any help, greatly appreciate, as always.

Cheers,

Chris

A: 

Use a CGAffineTransform.

Edit:

I am afraid I don't know what you mean by "rotating an object along a diagonal axis". What you most likely need to do is to concatenate two or more transforms.

See figure 5-8 in Quartz 2D programming Guide The concatenation of two transforms creates the appearance of the image rotating around its lower left corner.

TechZen
Hey there,Yes, I understand that that is the method to use, but HOW do I use it. When I do AffineTransformMakeRotation, it rotates the layer so that instead of having a square I get a diamond.What I am looking for is a way to rotate the underlying coordinate system so that the X-axis goes from -X,+Y to +X,-Y, but the layer does not rotate.Is that possible? Would it work for what I am trying to do? Or is there an even easier/better way of rotating an object along a diagonal axis?Thanks!Chris
Raconteur
See my edit for a more idea.
TechZen
Thanks, TZ. That helps. I was able to get what I wanted with this bit of code:CATransform3DConcat(((FlippingLayerTestView *)[self view]).lyr.transform, CATransform3DRotate(CATransform3DIdentity, M_PI/2, -1, 1, 0));
Raconteur