0

我正在为 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"];

老实说,我不知道是什么让这些白线出现,但我可以告诉你它们出现在动画中......我很难过这个任何帮助将不胜感激

4

1 回答 1

0

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

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

线条会消失。

于 2013-02-12T05:31:46.327 回答