0

我想恢復路徑繪圖的方向。所以我改變了價值和價值propeties,但是現在完整路徑在動畫開始時是可見的並且它開始消失。 我有路徑:改變筆畫動畫的方向

UIBezierPath* bezierPath = [UIBezierPath bezierPath]; 


    [bezierPath moveToPoint: CGPointMake(213.79, 170.83)]; 
    [bezierPath addCurveToPoint: CGPointMake(131.93, 95) controlPoint1: CGPointMake(212.14, 128.68) controlPoint2: CGPointMake(176.13, 95)]; 
    [bezierPath addCurveToPoint: CGPointMake(50, 173.85) controlPoint1: CGPointMake(86.68, 95) controlPoint2: CGPointMake(50, 130.3)]; 
    [bezierPath addCurveToPoint: CGPointMake(131.93, 252.7) controlPoint1: CGPointMake(50, 217.4) controlPoint2: CGPointMake(86.68, 252.7)]; 
    [bezierPath addCurveToPoint: CGPointMake(157.55, 248.76) controlPoint1: CGPointMake(140.88, 252.7) controlPoint2: CGPointMake(149.49, 251.32)]; 
    [bezierPath addCurveToPoint: CGPointMake(209.69, 281) controlPoint1: CGPointMake(166.59, 267.78) controlPoint2: CGPointMake(186.54, 281)]; 
    [bezierPath addCurveToPoint: CGPointMake(267, 225.85) controlPoint1: CGPointMake(241.34, 281) controlPoint2: CGPointMake(267, 256.31)]; 
    [bezierPath addCurveToPoint: CGPointMake(213.79, 170.83) controlPoint1: CGPointMake(267, 196.71) controlPoint2: CGPointMake(243.53, 172.86)]; 
    [bezierPath closePath]; 


    [color0 setStroke]; 
    bezierPath.lineWidth = 11; 
    [bezierPath stroke]; 

與動漫:

UIColor* color = [UIColor colorWithRed: 0.369 green: 0.42 blue: 0.475 alpha: 1]; 

    UIBezierPath *bezierPath = [self bezierPath]; 


    CAShapeLayer *bezier = [[CAShapeLayer alloc] init]; 

    bezier.path   = bezierPath.CGPath; 
    bezier.lineCap  = kCALineCapRound; 
    bezier.strokeColor = color.CGColor; 
    bezier.fillColor  = [UIColor clearColor].CGColor; 
    bezier.strokeStart = 1.0; 
    bezier.strokeEnd  = 0.0; 
    bezier.lineWidth  = 8.0; 
    bezier.strokeStart = 0.0; 
    bezier.strokeEnd  = 1.0; 
    [self.view.layer addSublayer:bezier]; 

    if (animate) 
    { 
     CABasicAnimation *animateStrokeEnd = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; 
     animateStrokeEnd.duration = appDelegate.myPlayer.audioPlayer.duration; 
     animateStrokeEnd.fromValue = [NSNumber numberWithFloat:1.0f]; 
     animateStrokeEnd.toValue = [NSNumber numberWithFloat:0.0f]; 
     [bezier addAnimation:animateStrokeEnd forKey:@"strokeEndAnimation"]; 
    } 

回答

6

你在正確的軌道上,但你應該有動畫的strokeStart屬性。

先以strokeStartstrokeEnd爲1.0開頭。

然後從 1.0 0.0動畫strokeStart。這會給你從開始到結束的路徑的影響。

例如,當25%的路徑被加速時,您將有strokeStart爲0.75,strokeEnd爲1.0。

+0

你說得很對。謝謝! – artsel 2013-05-10 17:36:38