如何在动画期间剪辑 UILabel?

发布于 2024-09-16 01:47:38 字数 201 浏览 8 评论 0原文

我正在自定义按钮上设置 UILabel 动画。我希望它看起来好像 UILabel 从右侧“滚动到”按钮上。

我的计划是将标签定位在按钮右侧 50 像素处,开始动画,将其移动到正确的位置,然后提交动画。然而,在整个动画中,我想将标签剪辑到按钮的框架上,这样您只能看到与按钮重叠的标签部分,而没有任何内容悬挂在右侧。

最好的方法是什么?

谢谢。

I am animating a UILabel over a custom button. I want it to appear as though the UILabel is "rolling onto" the button from the right.

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. 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别念他 2024-09-23 01:47:38

您应该能够在制作动画之前将标签添加为按钮的子视图。然后将按钮的 ClipsToBounds 属性设置为 YES。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文