您的位置:首页 > 大数据 > 人工智能

关于旋转动画只能画少一个pai 的问题

2014-10-10 17:01 302 查看
转载自:http://blog.csdn.net/zhibudefeng/article/details/8691567
CABasicAnimation *rotationAnimation = [CABasicAnimationanimationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumbernumberWithFloat:2*M_PI*0.722];
    rotationAnimation.duration =
1.0f;
    rotationAnimation.repeatCount =
MAXFLOAT;
    rotationAnimation.autoreverses =
YES;
    rotationAnimation.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    [self.pointerImageView.layeraddAnimation:rotationAnimation
forKey:nil];

用下面这种方法则只会花半个圆: 

CGAffineTransform  transform;
    transform = CGAffineTransformRotate(self.pointerImageView.transform,2*M_PI*0.722);
    [UIView beginAnimations:@"rotate" context:nil ];
    [UIViewsetAnimationDuration:2];
    [UIViewsetAnimationDelegate:self];
    [self.pointerImageView  setTransform:transform];
    [UIView commitAnimations];

如果想动画执行一次后停止在当前位置 ,则应该这么做:

CABasicAnimation *rotationAnimation = [CABasicAnimation
animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber
numberWithFloat:2*M_PI*0.722];
    rotationAnimation.duration =
1.5f;
    rotationAnimation.repeatCount =
0;
    rotationAnimation.autoreverses =
NO;
    rotationAnimation.removedOnCompletion =
NO; //要实现完成动画后停止在当前位置 
这个值应该设置成NO  然后下边的kCAFillModeForwards这个才会起作用
    rotationAnimation.fillMode =
kCAFillModeForwards;
    rotationAnimation.delegate =
self;
    rotationAnimation.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    [self.pointerImageView.layer
addAnimation:rotationAnimation forKey:@"KeyStartSwing"];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: