sjh15297195015dl 2014-12-31 06:18 采纳率: 100%
浏览 980

多个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];
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看