开发者

uiview CGAffineTransform animates backwards

I have a UIView subclass which I am able to successfully use UIView animations on.

This UIView also has subviews, which I also want to be able to UIView animate.

However, it seems that whenever I create an animation and apply it to the parent view it works fine, but if I apply the animation to the child view it animates backwards.

For example, if I scale my UIView parent(self) by a factor of 2 (to double the width and height):

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration:2];
[UIView setAnimationDelay:2];

CGAffineTransform scaleTransform = CGAffineTransformScale( self.transform, 2, 2  );
self.transform = scaleTransform;
[UIView commitAnimations];

then this works fine.

But if I do the same on the child:

UIView *myObj = [[self subviews] objectAtIndex:0];

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration:2];
[UIView setAnimationDelay:2];

CGAff开发者_如何学PythonineTransform scaleTransform = CGAffineTransformScale( myObj.transform, 2, 2  );
myObj.transform = scaleTransform;
[UIView commitAnimations];

It doesn't work. What happens visually is that the child view immediately shrinks down and then after the delay scales back up to it's original size.

If I log the transform parameters it looks the same for both parent and child and I have tried setting CGAffineTransformIdentity.

Any ideas what might be the problem?


I was overriding layoutSubviews and in there I was assigning sizes/positions of the views based upon device orientation which was conflicting.doh!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜