與iOS的Xcode,我有一個畫線。 我想立即刪除它(或消失)。 我試着重複代碼的顏色設置爲清除(紅色的測試),因爲我的背景是網格模式。但我只畫出最後一條綵線。 關於按順序依次繪製線條的任何想法?畫線然後刪除它
{
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0.0,100.0)];
[path addLineToPoint:CGPointMake(150.0, 100.0)];
[path addLineToPoint:CGPointMake(155.0, 50.0)];
[path addLineToPoint:CGPointMake(160.0, 150.0)];
[path addLineToPoint:CGPointMake(165.0, 100.0)];
[path addLineToPoint:CGPointMake(350.0, 100.0)];
CAShapeLayer *pathLayer = [CAShapeLayer layer];
pathLayer.frame = self.view.bounds;
pathLayer.path = path.CGPath;
pathLayer.strokeColor = [[UIColor greenColor] CGColor];
pathLayer.fillColor = nil;
pathLayer.lineWidth = 2.0f;
pathLayer.lineJoin = kCALineJoinBevel;
[self.view.layer addSublayer:pathLayer];
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 1.0;
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
[pathLayer addAnimation:pathAnimation forKey:@"strokeEnd"];
}
感謝
見這個問題的答案的層上進出動畫淡入:http://stackoverflow.com/questions/8707104/coreanimation-opacity-fade-in-and-out-animation-not-工作 – Jenn
謝謝,但似乎無法進入鏈接中的任何cade沒有很多錯誤。 '函數的隱式聲明'CMTimeGetSeconds在C99中無效'&'隱式聲明函數'CMTimeAdd'在C99中使用&'使用未聲明的標識符'img''&'使用未聲明的標識符'_timeline';你的意思是'時區'嗎?' &'使用未聲明的標識符'titleLayer'' – user2963333