开发者

iphone - Strang behavior when I set a UIImageView's frame while is in CGAffineTransformMakeScale animation

I have a UIImageView showing an image with the contentMode of UIViewContentModeScaleAspectFill.

Then I am associating a animation (about 30 seconds) of CGAffineTransformMakeScale with the UIImageView.

imageView.transform = CGAffineTransformMakeScale(1,1);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:30];
imageView.transform = CGAffineTransformMakeScale(1.9,1.9);
[UIView commitAnimations];

After 30 seconds, when a round of animation is done, I will set another image to the imageView and restart the animation.

Everything is fine. But when I try to rotate the UIImageView to adapt user's selection of device orientation, it becomes wired.

When the user is about to change the orientation, I set the UIImageView's frame to CGRectMake(0, 0, 768, 1004) or CGRectMake (0, 0, 1024, 748), accordingly.

The strange thing is:

if the frame of UIImageView is changed while the animation, it is fine. But when the next image comes and starts a new round of animation, the UIImageView 开发者_开发百科suddenly became small in the center of screen (is supposed to be full screen) and then the animation of zoom-in started as usual, just not full screen any more.

Can anyone tell me how to control the frame or orientation while the UIImageView has a transform with it?

Because I guess this is where it went wrong.

Thanks


Quoth the documentation for the frame property:

Warning: If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.

You should probably be messing with center and bounds instead, if you are using transformations.


Frame property is not defined when transforming. Use bounds instead of frame in this case.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜