I have a 100x100 pixel image that I want to draw at various angles rotated around the center of the image. The following code works, but rotates around the original origo of the coordinate system (upper left hand corner) and not the translated location. Thus the image is not rotated around itself but around the upper left corner of the screen.
The following code was run in a custom view in a blank application with nothing else but this.
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, -50, -50);
CGContextRotateCTM (context, 0.3);
CGContextTranslateCTM(context,768/2,1024/2);
[image drawAtPoint:CGPointMake(0,0)];
}
I tried doing the same using CGAffineTransform, but got the same results.