开发者

Is there a way to animate setClipsToBounds on UIView?

开发者 https://www.devze.com 2023-04-07 06:55 出处:网络
I would like to clip overflowing conten开发者_如何学Got using setClipsToBound:YES but I want the extraneous content to fade out. Is this possible? I tried UIView beginAnimations and it doesn\'t seem t

I would like to clip overflowing conten开发者_如何学Got using setClipsToBound:YES but I want the extraneous content to fade out. Is this possible? I tried UIView beginAnimations and it doesn't seem to take effect.


There are a limited number of properties that are animatable and I don't think clipsToBounds is one of them. Only thing I can think of is temporarily, at least, make two copies of your view.

When both views are visible, it will look like the view does not clip. To fade to clipping, animate the alpha of the non-clipping view to 0.0. When the animation completes you can discard the non-clipping view if you want. To fade back to non-clipping, add the non-clipping view back and animate its alpha back to 1.0. When the animation is complete, you can discard the clipping view if you want. Might be necessary to set the opaque setting on the non-clipping view to NO.

If the view contains contents that have their own alpha values, it probably will not look undetectable what's happening. But otherwise it should look for all intents and purposes like fading only the out-of-bounds portions.

0

精彩评论

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