`
yangping_Account
  • 浏览: 191752 次
  • 性别: Icon_minigender_1
  • 来自: 无锡
社区版块
存档分类
最新评论

CABasicAnimation

 
阅读更多

    //移动

    CABasicAnimation *translation = [CABasicAnimation animationWithKeyPath:@"position"];

    translation.fromValue = [NSValue valueWithCGPoint:CGPointMake(24, 240)];

    translation.toValue = [NSValue valueWithCGPoint:CGPointMake(320- 24, 240)];

    translation.duration = 2;

    translation.repeatCount = HUGE_VALF;

    translation.autoreverses = YES;

 

    //转动

    CABasicAnimation *rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];

    //kCAMediaTimingFunctionLinear 表示时间方法为线性,使得足球匀速转动

    rotation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

    rotation.toValue = [NSNumber numberWithFloat:4 * M_PI];

    rotation.duration = 2;

    rotation.repeatCount = HUGE_VALF;

    rotation.autoreverses = YES;

 

    [soccer.layer addAnimation:rotation forKey:@"rotation"];

    [soccer.layer addAnimation:translation forKey:@"translation"];

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics