tags:

views:

67

answers:

1

double angle = -15;
UIImage *image = [UIImage imageNamed:@"test.jpg"];
CGSize s = {image.size.width, image.size.height};
UIGraphicsBeginImageContext(s);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(ctx, 0,image.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextRotateCTM(ctx, 2*M_PI*angle/360);
CGContextDrawImage(ctx,CGRectMake(0,0,image.size.width, image.size.height),image.CGImage);
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Hi,I wont to rotate UIImage in image center point. I can rotate UIImage with this code,but not in center point.

Please help me.

+1  A: 

Use Core Animation. You can say

UIView.layer.anchor = aPoint;

Then, preform the rotation using the CA framework, and it will happen around that anchor.

DexterW