【发布时间】:2012-11-02 14:17:36
【问题描述】:
可能重复:
Any quick and dirty anti-aliasing techniques for a rotated 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。
此代码运行良好,但是边框和包含图像的线条不流畅,这破坏了我的应用程序的显示。
有谁知道这可能是什么原因造成的,或者如何解决。干杯
【问题讨论】:
-
什么不流畅?图片(视图)和边框,还是图片视图和边框的动画?
-
哦,我的解释很糟糕。查看更新的问题。
-
在动画中使用duration属性,然后也使用CAMeidaTimingFunction使其更加明显。
标签: iphone objective-c ios cocoa-touch