如何在ios中获得旋转UIView的完美X,Y位置

时间:2016-01-13 10:09:57

标签: ios rotation position cabasicanimation

我正在使用CABasicanimation来旋转UIView。我正在使用此代码,

    CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    NSNumber *currentAngle = [CircleView.layer.presentationLayer valueForKeyPath:@"transform.rotation"];
    rotationAnimation.fromValue = currentAngle;
    rotationAnimation.toValue = @(50*M_PI);
    rotationAnimation.duration = 50.0f;             // this might be too fast
    rotationAnimation.repeatCount = HUGE_VALF;     // HUGE_VALF is defined in math.h so import it
    [CircleView.layer addAnimation:rotationAnimation forKey:@"rotationAnimationleft"];

在这里我想要完美的X,Y位置,而#34; UIView"在旋转。 如果有人知道请帮助我。

提前谢谢。enter image description here

2 个答案:

答案 0 :(得分:2)

我得到了这个问题的答案请转到此链接进行解答

py2exe options

答案 1 :(得分:0)

所以,如果我理解正确,你只想在旋转过程中获得视图的X和Y坐标?

您可以通过记录presentationLayer的框架来完成此操作,如下所示:

- (IBAction)buttonAction:(UIButton *)sender {

    CGRect position = [[CircleView.layer presentationLayer] frame];
    NSLog(@"%@", NSStringFromCGRect(position));
}