har*_*yas 10 position rotation cabasicanimation ios
我正在使用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"];
Run Code Online (Sandbox Code Playgroud)
在这里我想要完美的X,Y位置,而"UIView"正在旋转.如果有人知道请帮助我.
那么,如果我理解正确的话,您只想在旋转过程中获取视图的 X 和 Y 坐标?
您可以通过记录presentationLayer的框架来做到这一点,如下所示:
- (IBAction)buttonAction:(UIButton *)sender {
CGRect position = [[CircleView.layer presentationLayer] frame];
NSLog(@"%@", NSStringFromCGRect(position));
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
997 次 |
最近记录: |