Hardik Vyas
Hardik Vyas

Reputation: 2253

How to get current position of animating uiview in ios

I want current position of animating UIView during animation and I am using this code.

CABasicAnimation * m_pAnimationObj = [CABasicAnimation animationWithKeyPath:@"transform.translation"];
[m_pAnimationObj setFromValue:[NSValue valueWithCGPoint:CGPointMake(0,-50)]];
[m_pAnimationObj setToValue:[NSValue valueWithCGPoint:CGPointMake(0,[UIScreen mainScreen].bounds.size.height+100)]];
m_pAnimationObj.duration = 2.0;
m_pAnimationObj.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[DropImage.layer addAnimation:m_pAnimationObj forKey:@"animations"];

Please answer if anyone knows about this. Thank you in advance!

Upvotes: 0

Views: 792

Answers (1)

Aruna Mudnoor
Aruna Mudnoor

Reputation: 4825

Use this code:

CGRect currentCenter = [drawingView.layer.presentationLayer center];

or

CGRect currentFrame = [DropImage.layer.presentationLayer frame];

Upvotes: 4

Related Questions