1
votes

I'm trying to rotate my image, but not by 90 degrees or 180, I don't actually know the amount I want to rotate by. If I could get rotation to work, I'd just kinda do guess and check with the rotation amount, however I can't get the image to rotate. I've looked up numerous questions similar to this and they all use M_PI or something similar to that. I put that in my code and nothing happens, the image never rotates. Can someone please help me get the image to rotate.

Box6 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"border.png"]];
Box6.center = CGPointMake(StickFigure.center.x + 22, StickFigure.center.y + 19);
Box6.transform = CGAffineTransformMakeRotation(M_PI/45);

the M_PI/45 is not what I was using, I've just been messing around with numbers and nothing has been changing

1
Can you provide the code you use that should be performing the rotation?Adam Evans
@Aderis I added the codekarateman10998

1 Answers

2
votes

The function CGAffineTransformMakeRotation() takes the angle in radians, as seen in here in the docs, so by passing M_PI/45, you are rotating a total of 2 degrees, which you might be mistaking for no rotation. To test if your code actually works I would put in just M_PI, which is equivalent to 180 degrees. If you are working in degrees and need the radians equivalent, use this formula: radians = degrees * M_PI / 180