简体   繁体   English

如何在动画过程中剪辑UILabel?

[英]How can I clip a UILabel during animation?

I am animating a UILabel over a custom button. 我正在通过自定义按钮设置UILabel的动画。 I want it to appear as though the UILabel is "rolling onto" the button from the right. 我希望它看起来好像UILabel从右侧“滚动”到按钮上。

My plan is to position the label 50 pixels to the right of the button, begin animation, move it to its correct position, and commit animation. 我的计划是将标签放置在按钮右侧50像素处,开始动画处理,将其移动到正确位置,然后提交动画。 However, throughout the animation I want to clip the label to the frame of the button, so that you only see the piece of the label that overlaps the button and nothing hanging over to the right. 但是,在整个动画过程中,我都希望将标签剪切到按钮的框架上,以便仅看到与按钮重叠的标签部分,而没有任何东西悬在右侧。

What's the best way to do this? 最好的方法是什么?

Thanks. 谢谢。

You should be able to add the label as a subview of your button before animating. 设置动画之前,您应该能够将标签添加为按钮的子视图。 Then set your the clipsToBounds property of your button to YES. 然后将按钮的clipsToBounds属性设置为YES。

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

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