1
votes

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.

Transform Search

Any other ideas?

1
I just tried your code and it does work for me as expected with no skew, I'd assume that something else affects you image viewSash Zats
this is the only function in the code that does any form of transformation on the image view. - no it isn't, it's just the only code that you think is performing translations on the image view :)deanWombourne

1 Answers

1
votes

Ok I found the issue, not sure on the "why" but the solution was to change the image view draw mode from "Scale to Fill" to "Center"

I am at a total loss as to why this would affect offsetting an angle by a constant?? enter image description here