与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