iphone - 当我在 CGAffineTransformMakeScale 动画中设置 UIImageView 的框架时出现奇怪的行为
我有一个 UIImageView 显示带有 UIViewContentModeScaleAspectFill 的 contentMode 的图像。
然后我将 CGAffineTransformMakeScale 的动画(大约 30 秒)与 UIImageView 关联起来。
imageView.transform = CGAffineTransformMakeScale(1,1);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:30];
imageView.transform = CGAffineTransformMakeScale(1.9,1.9);
[UIView commitAnimations];
30秒后,当一轮动画完成时,我将向imageView设置另一个图像并重新启动动画。
一切都很好。但是当我尝试旋转 UIImageView 以适应用户对设备方向的选择时,它变得有线。
当用户要更改方向时,我将 UIImageView 的框架相应地设置为 CGRectMake(0, 0, 768, 1004) 或 CGRectMake (0, 0, 1024, 748)。
奇怪的是:
如果UIImageView的frame在动画的时候改变了,也没有问题。但是当下一个图像到来并开始新一轮动画时,UIImageView突然在屏幕中心变小(应该是全屏),然后放大动画照常开始,只是不再全屏了。
谁能告诉我如何在 UIImageView 进行变换时控制框架或方向?
因为我猜这就是出错的地方。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
引用
frame
属性的文档:如果您正在使用转换,您可能应该弄乱
center
和bounds
。Quoth the documentation for the
frame
property:You should probably be messing with
center
andbounds
instead, if you are using transformations.变换时未定义框架属性。在这种情况下,使用边界而不是框架。
Frame property is not defined when transforming. Use bounds instead of frame in this case.