问题
I am using CABasicanimation for rotate an UIView. I am using this code,
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"];
in this i want perfect X,Y position while "UIView" is rotating. If anyone know please help me.
Thank you in advance.
回答1:
I Got A Answer Of This Question Please Go To This Link For Answer
Go to This Link For Answer
回答2:
So, if I understand you correctly, you just want to get the X and Y coordinates of your view during rotation?
You can do this by logging the frame of the presentationLayer, like this:
- (IBAction)buttonAction:(UIButton *)sender {
CGRect position = [[CircleView.layer presentationLayer] frame];
NSLog(@"%@", NSStringFromCGRect(position));
}
来源:https://stackoverflow.com/questions/34763819/how-to-get-perfect-x-y-position-of-rotating-uiview-in-ios