开发者

How can I rotate UIImage on clicking rotate button

开发者 https://www.devze.com 2023-03-18 10:56 出处:网络
I would like to rotate UIImage not the UIImageView on clicking rotate button n开发者_JAVA技巧ot on orientation change. Please reply.CGSize size =sizeOfImage;

I would like to rotate UIImage not the UIImageView on clicking rotate button n开发者_JAVA技巧ot on orientation change. Please reply.


CGSize size =  sizeOfImage;
UIGraphicsBeginImageContext(size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextRotateCTM(ctx, angleInRadians);
CGContextDrawImage(UIGraphicsGetCurrentContext(),
  CGRectMake(0,0,size.width, size.height),
  image);

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


You can use imageWithCGImage:scale:orientation: (available from 4.0)


Edited:

use http://developer.apple.com/library/ios/documentation/uikit/reference/UIImage_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006890-CH3-SW37 for IOS 4 , if you want to rotate image

or you can use: http://www.platinumball.net/blog/2010/01/31/iphone-uiimage-rotation-and-scaling/

or

  • http://blog.logichigh.com/2008/06/05/uiimage-fix/
0

精彩评论

暂无评论...
验证码 换一张
取 消