0

可能重复:
旋转 UIImageView 的任何快速而肮脏的抗锯齿技术?

我的应用程序中有一个带有边框的图像视图(myImage):

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

然后我使用以下代码将其旋转,在本例中旋转 20 度。

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"];

上面的代码旋转了图像,但您看不到它的动画效果(因为 imageRotation.duration 非常低)。旋转完成后,结果是一个图像视图,它没有移动或旋转,但已经旋转了 20。

这段代码工作正常,但是边框和包含图像的线条都不平滑,这破坏了我的应用程序的显示。

有谁知道这可能是什么原因造成的,或者如何解决它。干杯

4

2 回答 2

0

尝试

CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
于 2012-11-02T14:32:20.833 回答
0

您是否尝试过在 imageView 中使用 transform 属性?尝试这个 :

myImage.transform = CGAffineTransformMakeRotation((r*M_PI)/ -180);
于 2012-11-02T14:33:57.470 回答