三角形を UIView 境界の外から UIView 領域に移動しようとしています。
UIBezierPath を使用しています。
三角形が領域外にある間は、見えないようにしたいです。UIView の内側にある三角形の部分だけを表示したい。
残念ながら、アニメーション全体で表示されます (境界の外側と内側の間)。
これは私のコードです:
UIBezierPath *triangle = [UIBezierPath bezierPath];
[triangle moveToPoint:CGPointMake(X, Y)];
[triangle addLineToPoint:CGPointMake(X - (width*0.5), Y)];
[triangle addLineToPoint:CGPointMake(X, Y + (width*0.5))];
[triangle closePath];
CAShapeLayer *triLayer = [CAShapeLayer layer];
triLayer.frame = testView.bounds;
triLayer.path = triangle.CGPath;
triLayer.strokeColor = [[UIColor redColor] CGColor];
triLayer.fillColor = [[UIColor yellowColor] CGColor];
[testView.layer addSublayer:triLayer];
CABasicAnimation *triangleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
triangleAnimation.duration=0.5;
triangleAnimation.repeatCount=1;
triangleAnimation.autoreverses=NO;
triangleAnimation.fromValue=[NSNumber numberWithFloat:(width*0.5)];
triangleAnimation.toValue=[NSNumber numberWithFloat:0];
triangleAnimation.removedOnCompletion = NO;
triangleAnimation.fillMode = kCAFillModeForwards;
[triLayer addAnimation:triangleAnimation forKey:@"animateLayer"];