动画 UIImageView 离开屏幕
我有一个 UIImageView
,我需要在屏幕上设置动画。我通过在 1 秒动画块中将帧调整为 0 来实现此目的。如果我不考虑内容类型(这是缩放类型之一),它会按照我的意愿缩小到 0,但在调整到新的帧大小时会挤压图像。 我需要它只是剪掉底部。我将内容类型更改为左上角,这导致它不执行任何操作。
我在这里缺少什么?
这是动画块代码。
// Change frame height.
[UIView animateWithDuration:1.0f
animations:^ {
// Animate the frame off the screen
_closeImage.frame = CGRectMake(_closeImage.frame.origin.x, _closeImage.frame.origin.y, _closeImage.frame.size.width, 0);
}
];
I have a UIImageView
that I need to animate off the screen. I'm doing this by adjusting the frame to 0 in a 1 second animation block. If I leave the content type alone, which is one of the scaling types, it will shrink to 0 as I want it to, but it will pinch the image as it adjusts to the new frame size. I need it to just crop the bottom off instead. I changed the content type to top left and that causes it to not do anything.
What am I missing here?
Here's the animation block code.
// Change frame height.
[UIView animateWithDuration:1.0f
animations:^ {
// Animate the frame off the screen
_closeImage.frame = CGRectMake(_closeImage.frame.origin.x, _closeImage.frame.origin.y, _closeImage.frame.size.width, 0);
}
];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想要更改
scaleMode
属性。如果您希望它在正确缩放的同时缩小,您可以将其更改为宽高比。否则,您可以尝试其他一些。编辑:
根据您的评论,您需要设置
clipsToBounds
属性。You want to change the
scaleMode
property. You can change it to aspect fit if you want it to shrink while scaling correctly. Otherwise, you can try some of the other ones.EDIT:
As per your comment, you need to set the
clipsToBounds
property.您可以尝试使用:
_parentView 是包含 imageview 的视图...它将从parentView 上滑落,如果您不再使用它,请考虑将其从超级视图中删除...
You can try with:
_parentView is view containing imageview... it will slide off parentView, and consider removing it from superview afterwards if you dont use it anymore...