I'm trying to rotate an UIView
a few radians but after applying the transformation it doesn't look to be keeping its size. What's the proper way to achieve this?
Here's what I'm doing and what I get (Blue box with the arrow is the View I'm trying to rotate -- it should keep same aspect as red box behind):
#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)
double rads = DEGREES_TO_RADIANS(240);
CGAffineTransform transform = CGAffineTransformRotate(CGAffineTransformIdentity, rads);
self.arrowView.transform = transform;
Thanks!
The
CGAffineTransformRotate
transformation rotates from an existing affine transform. The fact that you are usingCGAffineTransformIdentity
might be the issue. You must specify the current transform of your view.Also, you might want to consider:
EDIT : If you can, share what you kind of transformation (animated/inanimate , single/iterative) you want to achieve. I believe there might be a better, optimized way of doing this.
Try with this code: