I have a rather puzzling problem. I have a UIImageView to which I supply an angle in radians to a function that rotates it. It works fine, however I now want to offset the angle by a constant. Funny thing is if I do any sort of division or multiplication to the offset variable against M_PI the imageview is skewed and not rotated??
- (void)rotateDialToAngle: (CGFloat)angle {
CGFloat offsetAngle = -0.075f * (2.0f * M_PI);
offsetAngle += angle;
if(offsetAngle >= M_PI * 2)
offsetAngle -= M_PI * 2;
if(offsetAngle < 0)
offsetAngle += (M_PI * 2);
self.clockDialImageView.transform = CGAffineTransformMakeRotation(offsetAngle);
}
The code above is the intended state. If I replace the offSetAngle calculation with M_PI it has the expected behaviour of offsetting the rotation by 180 degrees. If I replace it with M_PI / 2 or anything else, I get the skew behaviour.
The if statements are used to clamp the degrees to positive degrees no greater than 360. These work as expected.
Note: this is the only function in the code that does any form of transformation on the image view.
Note 2: Although the view is skewed, the rotation is still applied.
Edit: Additional transforms in the code does not explain how the problem is SO isolated to a single line of code and an operation on a constant in that line. Edit: Looked for other transforms - Nothing. CMPopTipView is external to this controller and not used. As is DejalActivityView.
Any other ideas?