开发者

UIView Animation iPhone (obtaining information on the frame dynamically)

开发者 https://www.devze.com 2022-12-23 16:53 出处:网络
I have a UIView called goalBar which is being animated by increasing the size of the frame according to a float value called destination:

I have a UIView called goalBar which is being animated by increasing the size of the frame according to a float value called destination:

CGRect goalBarRect = CGRectMake(0, 0, destination, 29);

[UIView beginAnimations:@"goal" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:2.0f];

goalBar.frame = goalBarRect;

[UIView commitAnimations];

开发者_开发百科The animation works perfectly and the rectangular view increases its width over the course of the animation (from 0 to the value for destination).

However, I wish to be able to extract the values for the frame of the UIView being animated (i.e. goalBar) as the animation takes place. By that I mean that I wish to place the value of the width for the animated frame in a separate UILabel so that the user sees a counter that provides the width of the UIView as it's being animated.

Any help on how to do the above would be gratefully received.


How about observing the frame property of the view. So that you get callbacks when it changes.

See Key-Value Observing.


I've looked into this and it seems that it is not possible to get updates on the state of the components being animated during the UIView animation process.

0

精彩评论

暂无评论...
验证码 换一张
取 消