u013782653
sjh15297195015dl
采纳率100%
2014-12-31 06:18

多个UIBezierPath拼接起来的运动轨迹,在我执行动画的时候,整个的动画效果会出现卡顿,

执行动画的代码:
CAKeyframeAnimation *keyframeAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
keyframeAnimation.path = dr.aPath.CGPath;
keyframeAnimation.repeatCount=1;
keyframeAnimation.removedOnCompletion = NO;
keyframeAnimation.fillMode = kCAFillModeForwards;
keyframeAnimation.duration = 4.0f;
keyframeAnimation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
keyframeAnimation.delegate=self;
[imageView.layer addAnimation:keyframeAnimation forKey:nil];

 画的动画路径:
 - (void)drawRect:(CGRect)rect {

    UIColor *color = [UIColor redColor];
    [color set];
    _aPath = [UIBezierPath bezierPath];
    [_aPath addArcWithCenter:CGPointMake(self.center.x, self.center.y-50) radius:50 startAngle:M_PI_2 endAngle:M_PI*2.f*3/4 clockwise:YES];
    [_aPath addArcWithCenter:CGPointMake(self.center.x, self.center.y) radius:100 startAngle:-M_PI_2 endAngle:M_PI*2.f*3/4 clockwise:YES];// 逆时针
    [_aPath addArcWithCenter:CGPointMake(self.center.x, self.center.y) radius:100 startAngle:-M_PI_2 endAngle:M_PI*2.f*3/4/3 clockwise:YES];// 逆时针
    [_aPath addArcWithCenter:CGPointMake(self.center.x, self.center.y+50) radius:50 startAngle:M_PI_2 endAngle:M_PI*2.f*3/4 clockwise:YES];
    _aPath.lineWidth = 5.0;
    _aPath.lineCapStyle = kCGLineCapRound; //线条拐角
    _aPath.lineJoinStyle = kCGLineCapRound; //终点处理
    [_aPath stroke];
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

为你推荐