How to get perfect X , Y position of rotating UIView in ios

匿名 (未验证) 提交于 2019-12-03 00:46:02

问题:

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)); } 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!