繁体   English   中英

在屏幕外为 UIImageView 设置动画

[英]Animating a UIImageView off the screen

我有一个UIImageView我需要在屏幕上设置动画。 我通过在 1 秒 animation 块中将帧调整为 0 来做到这一点。 如果我不理会作为缩放类型之一的内容类型,它会按照我的意愿缩小到 0,但它会在调整到新的帧大小时挤压图像。 我需要它来代替裁剪底部 我将内容类型更改为左上角,这导致它不执行任何操作。
我在这里想念什么?

这是 animation 块代码。

// 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);
                 }
 ];

您想要更改scaleMode属性。 如果您希望它在正确缩放时缩小,您可以将其更改为宽高比。 否则,您可以尝试其他一些。

编辑:

根据您的评论,您需要设置clipsToBounds属性。

您可以尝试:

    // Change frame placement.
[UIView animateWithDuration:1.0f
                 animations:^ {
                     // Animate the frame off the screen
                     _closeImage.frame = CGRectMake(_closeImage.frame.origin.x, _parentView.frame.size.height, _closeImage.frame.size.width, _closeImage.frame.size.height);
                 }
 ];

_parentView 是包含 imageview 的视图...它会滑出 parentView,如果您不再使用它,请考虑将其从超级视图中删除...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM