0

Possible Duplicate:
Any quick and dirty anti-aliasing techniques for a rotated UIImageView?

I have an image view (myImage) in my app which has a border:

[myImage.layer setBorderColor: [[UIColor whiteColor] CGColor]];
[myImage.layer setBorderWidth: 1];

I am then using the following code to rotate it, in this case by 20 degrees.

NSInteger r = 20;
CABasicAnimation *imageRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
imageRotation.toValue = [NSNumber numberWithFloat:((r*M_PI)/ -180)];
imageRotation.duration = 0.01;
imageRotation.repeatCount = 1;
imageRotation.removedOnCompletion = NO;
imageRotation.autoreverses=NO;
imageRotation.fillMode = kCAFillModeForwards;
[myImage.layer addAnimation:imageRotation forKey:@"imageRotation"];

The code above rotates the image, but you cannot see it animated (because of the very low imageRotation.duration). After the rotation is complete the result is an image view, that is not moving or rotating, but has been rotated by 20.

This code is working fine, however the lines of both the border and containing image are not smooth which is ruining the display of my app.

Does anyone know what could be causing this, or how to resolve it. Cheers

Community
  • 1
  • 1
Patrick
  • 6,495
  • 6
  • 51
  • 78

2 Answers2

0

Try

CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
Mundi
  • 79,884
  • 17
  • 117
  • 140
0

Have you tried using the transform property in a imageView? try this :

myImage.transform = CGAffineTransformMakeRotation((r*M_PI)/ -180);
Yuliani Noriega
  • 1,085
  • 12
  • 23
  • Well, it goes without saying, this changes 8 lines to 1 line and is therefore better than the code I used. However, the edges of the border and image are still jagged. – Patrick Nov 02 '12 at 14:43