1
我有一個CAShapeLayer,我在那裏爲一個圓圈設置了動畫。動畫首先順時針「取消」圓形,然後順時針重繪圓形。排序的「旋轉圈」。放置它的另一種方法:移動路徑筆劃結束點以開始,然後將起始點移動到結尾。排隊CAAnimations時出現毛刺
動畫本身的作品,但它不時產生小故障。當它被認爲是「未提取的」時,它會在整個圓圈內看到一個短暫的瞥見。
爲什麼會發生這種情況,您如何解決?
感謝,
// Shape creation
layer.path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, self.width - 2 * OUTER_BORDER_WIDTH, self.width - 2* OUTER_BORDER_WIDTH)].CGPath;
// Animation queuing
-(void) applyNextAnimation
{
CABasicAnimation* animation;
if (self.animatingOpening)
{
animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
animation.fromValue = [NSNumber numberWithFloat:0.0f];
animation.toValue = [NSNumber numberWithFloat:1.0f];
self.animatingOpening = NO;
}
else
{
animation = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
animation.fromValue = [NSNumber numberWithFloat:0.0f];
animation.toValue = [NSNumber numberWithFloat:1.0f];
self.animatingOpening = YES;
}
animation.duration = 1.0f;
animation.autoreverses = NO;
animation.delegate = self;
animation.removedOnCompletion = YES;
[self.outerCircleLayer addAnimation:animation forKey:@"stroke"];
}
// Animation stop callback
-(void) animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
if (self.isAnimating)
{
[self applyNextAnimation];
}
}
好極了!我添加了'[CATransaction setDisableActions:NO];'在if-else語句的末尾保留了一個動畫,這裏沒有顯示。 (另一層) –
很高興它是有用的。我看到你正在處理一些涉及高頻傳感器數據存儲的有趣問題,所以我在其他問題中增加了一些想法。 – foundry