[英]How to get perfect X , Y position of rotating UIView in 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"];
在這里我想要完美的X,Y位置,而“UIView”正在旋轉。 如果有人知道請幫助我。
我得到了這個問題的答案請轉到此鏈接以獲得答案
所以,如果我理解正確,你只想在旋轉過程中獲得視圖的X和Y坐標?
您可以通過記錄presentationLayer的框架來完成此操作,如下所示:
- (IBAction)buttonAction:(UIButton *)sender {
CGRect position = [[CircleView.layer presentationLayer] frame];
NSLog(@"%@", NSStringFromCGRect(position));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.