Re: rotate UI subview (CFAffline Transform)
Re: rotate UI subview (CFAffline Transform)
- Subject: Re: rotate UI subview (CFAffline Transform)
- From: Cody Garvin <email@hidden>
- Date: Fri, 18 Jul 2014 06:50:48 -0700
Transforms are meant to be tiered / layered. In other words, if you do another transform via a pan or rotation, it’s going to reset. If your view was already scaled (matrix has been edited), doing a Make transform (ex: CGAffineTransformMakeRotation) would reset it. Transforms manipulate the layer(s). Your view isn’t aware the layer has been tampered with.
If it isn’t another transform that is resetting the layer, then you need to reapply your transform. You can can easily get your current transformation via:
CGAffineTransform transformation = theRotatedView.transform;
CGFloat amountRotated = atan2f(transformation.b, transformation.a); // b and a are the values manipulated for matrix math.
A debugging method that you can use is: NSStringFromCGAffineTransform(), will help output your current transform. I’m sure you’ll see the matrix numbers reset.
Regards
- Cody
It would help to see the code that makes the pan gesture.
> On Jul 18, 2014, at 4:51 AM, 2551 <email@hidden> wrote:
>
> I have a problem which I can't find anyone else asking after hours of searches through stackexchange and the like.
>
> In a UIView, I'm rotating a subview with a Gesture recognizer that calls this selector:
>
> - (IBAction)rotateShape:(UIRotationGestureRecognizer *)gesture {
> gesture.view.transform = CGAffineTransformMakeRotation(gesture.rotation);
> }
>
> The rotation performs as expected and all is right with the world. However, as soon as I attempt to touch or move the rotated subview again (it also has a pan gesture), it reverts to its original orientation.
>
> It seems the original transform values are still being retained and held by the object or by the drawing context (I'm still not quite comfortable with all the graphics theory; indeed, this is my first attempt at trying to unlock its mysteries). What else do I need to do to ensure the new rotated, orientation "sticks" so that I can move the shape without it reverting to the original orientation?
>
> Thanks for any help.
>
>
> Phil
> _______________________________________________
>
> 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
_______________________________________________
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