I want to rotate UIImage (not UIImageView) to a custom degree I followed this post , but this did not work for me.
Can anybody help? Thanks.
UPDATE: The code below performs some tasks, but I lose part of the image after rotating it:

What should I change to get it right? (By the way, the yellow color in the screenshots is my UIImageView bg)
- (UIImage *) rotate: (UIImage *) image { double angle = 20; 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(); return newImage; }
source share