2009-05-27 84 views

回答

14

你會想要做幾乎相同的東西,在該職位確實在旋轉之間旋轉:

CGSize size = sizeOfImage; 
UIGraphicsBeginImageContext(size); 
CGContextRef ctx = UIGraphicsGetCurrentContext(); 
CGContextRotateCTM(ctx, angleInRadians); 
CGContextDrawImage(ctx, (CGRect){{}, size}, image); 

UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 
return image; 

您可能還需要翻譯CTM以補償旋轉中心。如果你不想在旋轉時裁剪圖像的邊緣,你應該增加一些基本的三角形。