CAShaperLayer路径动画

时间:2016-09-03 03:45:25

标签: animation path

该函数是CAShaperLayer的路径动画,但是看左下角是坏的。我不知道原因,但删除了角落,一切都会好的!但事实是我需要这种视觉效果......

- (void)p_addShadow {
CGRect rect1 = CGRectInset(self.bounds, 10, 10);
CGRect rect2 = CGRectInset(self.bounds, -50, -50);

UIBezierPath *bezierPath1 = [UIBezierPath bezierPathWithRoundedRect:rect1 cornerRadius:CCWH6(10)];
UIBezierPath *bezierPath2 = [UIBezierPath bezierPathWithRoundedRect:rect2 cornerRadius:CCWH6(10)];

self.shaperLayer.path = bezierPath1.CGPath;
self.shaperLayer.lineWidth = 16;
self.shaperLayer.strokeColor = UIColorFromRGB(0xFFD962).CGColor;
self.shaperLayer.fillColor = [UIColor clearColor].CGColor;
self.shaperLayer.opacity = 0;

CAKeyframeAnimation *alpha = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
alpha.values = @[@(0), @(1), @(0)];

CABasicAnimation *path = [CABasicAnimation animationWithKeyPath:@"path"];
path.toValue = (__bridge id _Nullable)(bezierPath2.CGPath);

CABasicAnimation *lineW = [CABasicAnimation animationWithKeyPath:@"lineWidth"];
lineW.toValue = @(0);

CAAnimationGroup *group = [CAAnimationGroup animation];
group.animations = @[path, alpha, lineW];
group.duration = 1.0;
group.repeatCount = HUGE_VALF;
group.delegate = self;
[self.shaperLayer addAnimation:group forKey:nil];

}

============================================

效果:

the corner at left-bottom broken !!!!

拜托,谢谢!

0 个答案:

没有答案