开发者

Animating a UIImageView off the screen

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开发者_如何学Go 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);
                 }
 ];


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.


You can try with:

    // 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 is view containing imageview... it will slide off parentView, and consider removing it from superview afterwards if you dont use it anymore...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜