0
我在UIScrollView
上畫了一個UIBezierPath
我做了一個動畫,畫出了從開始到結束點的路徑,但這不是我想要的動畫。UIBezierPath脈衝動畫
UIBezierPath *linePath = [UIBezierPath bezierPath];
[linePath moveToPoint:startPoints];
[linePath addLineToPoint:endPoints;
//shape layer for the line
CAShapeLayer *line = [CAShapeLayer layer];
line.path = [linePath CGPath];
// line.fillColor = [[UIColor blackColor] CGColor];
line.strokeColor = [[colors objectAtIndex:i] CGColor];
line.lineWidth = 5;
// line.contents = (id)[[UIImage imageNamed:@"Mask.png"] CGImage];
// line.contentsGravity = kCAGravityCenter;
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = 3.0;
pathAnimation.fromValue = @(0.0f);
pathAnimation.toValue = @(1.0f);
pathAnimation.repeatCount = HUGE_VAL;
[line addAnimation:pathAnimation forKey:@"strokeEnd"];
我曾嘗試添加一個contents
的形狀圖層,但我不擅長動畫。我想實現的效果與「滑動解鎖」具有相同的動畫,或者是一個脈衝路徑。
我試圖做同樣的事情從slide-to-unlock答案,但似乎無法管理