CALayer薄白线

时间:2012-11-30 01:33:28

标签: xcode animation calayer caanimation

我正在动画一个CALayer移动,出于某种原因,我不断在屏幕上看到这些细白线...这不是我的设备我可以向你保证这里是我如何设置CALayer:

dodgelayer=nil;
dodgelayer= [CALayer layer];
dodgelayer.backgroundColor = [UIColor blueColor].CGColor;

dodgelayer.frame = CGRectMake(190, 80, 50, 50);
dodgelayer.borderColor = [UIColor whiteColor].CGColor;
dodgelayer.borderWidth = 2.0;
dodgelayer.cornerRadius = 50.0;

以及我如何设置动画:

        CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"position"];

      values = [NSArray arrayWithObjects:[NSValue valueWithCGPoint: CGPointMake(aLayer.frame.origin.x+25,aLayer.frame.origin.y+25)], [NSValue valueWithCGPoint: CGPointMake(point.x,point.y)], nil];
        [anim setValues:values];
        [anim setDuration:0.7];
        anim.removedOnCompletion=NO;
        anim.fillMode = kCAFillModeForwards;
        anim.timingFunction=[CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];
        sublayer.shouldRasterize=YES;
        [sublayer addAnimation:anim forKey:@"position"];

老实说,我不知道是什么让这些东西出现白线,但我可以告诉你,它们出现在动画中......我很难过这一点任何帮助都会受到赞赏

1 个答案:

答案 0 :(得分:0)

我自己就碰到了这个问题。 原因是shouldResterize = YES。 在调用之前,您应该设置

sublayer.rasterizationScale = [[UIScreen mainScreen] scale];

并且线条会消失。