我的应用程序中有一个带有边框的图像视图(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。
这段代码工作正常,但是边框和包含图像的线条都不平滑,这破坏了我的应用程序的显示。
有谁知道这可能是什么原因造成的,或者如何解决它。干杯