如何将标签添加到标签 [英] How to add marquee to a label

查看:134
本文介绍了如何将标签添加到标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的UIView顶部有一个标签。我在计时器的帮助下通过数组显示一些消息。但现在我希望这些消息以MARQUEE风格显示。我没有任何办法start.Any源代码,使用方法,任何动画风格,任何不同的方法。
提前致谢

I have a label at the top of my UIView.I am displaying some messages on it through array with the help of the timer.But now i want this messages to be displayed in MARQUEE style.I am not getting any way to start.Any source code,methods to use,any animation style,any different approach. Thanks in advance

推荐答案

这是一个想法:


  • 在你的UILabel所在的UIView上将clipsToBounds设置为true。

  • 然后启动一个UIViewAnimations块(在文档中查看如何使用它,它的非常简单)


    • 创建一个新标签,其框架设置为一个位于封闭UIView边界之外的位置

    • 将前一个标签的位置设置在封闭UIView边界之外的左侧某处。

    • 将下一个标签的位置设置为以前标签的位置。

    • Set clipsToBounds to true on the UIView that your UILabel is sitting in.
    • Then start a UIViewAnimations block (look in the docs for how to use it, its very simple)
      • Create a new label with its frame set to a position that is outside of the bounds of the enclosing UIView
      • set the previous label's position to somewhere to the left outside the bounds of the enclosing UIView
      • set the next label's position to where the previous label used to be.

      这应该会让你滑动移动屏幕的一个标签的动画和在屏幕上移动的新标签。

      That should give you the sliding animation of one label moving off screen and a new label moving on screen.

      你必须使用animationDuration属性以及精确的定位和大小调整属性。标签和视图让它恰到好处t,但它应该很简单。

      You'll have to play around with the animationDuration property and the precise positioning and sizing properties of the labels and views to get it just right, but it should be quite simple.

      这篇关于如何将标签添加到标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆