iOS实现跑马灯效果

在网页开发当中跑马灯是常用到的,用来显示通知等,在游戏开发当中也如此。

下面的代码片断可实现iOS中的跑马灯效果,

  1. [labelShow sizeToFit];
  2. CGRect frame = labelShow.frame;
  3. frame.origin.x = 320;
  4. labelShow.frame = frame;
  5. [UIView beginAnimations:@"testAnimation" context:NULL];
  6. [UIView setAnimationDuration:8.8f];
  7. [UIView setAnimationCurve:UIViewAnimationCurveLinear];
  8. [UIView setAnimationDelegate:self];
  9. [UIView setAnimationRepeatAutoreverses:NO];
  10. [UIView setAnimationRepeatCount:999999];
  11. frame = labelShow.frame;
  12. frame.origin.x = -frame.size.width;
  13. labelShow.frame = frame;
  14. [UIView commitAnimations];

labelShow是UILabel,关联到xib就行了。

时间: 2024-08-27 04:41:51

iOS实现跑马灯效果的相关文章

iOS LED跑马灯效果实现

iOS中实现LED跑马灯效果 实现原理是使用scrollView, 将需要滚动的label添加两次到 scrollView的subView下面, 然后通过滚动scrollView来实现跑马灯效果. 具体实现代码如下: // // KMScrollLabel.swift // StopSmokingPrograms // // Created by Fran on 15/11/2. // Copyright © 2015年 kimree. All rights reserved. // impor

iOS中跑马灯效果小结

时光过得好快,记忆中刚刚从春节返回没有多久,清明.五一已飞逝而过,眨眼已到盛夏季节.不过还好,济南这两年不算太热,刚开始升温几天,一场及时雨总能让温度保持适宜.为了纪念一下青春的尾巴,也为了能有个健康的身体和充沛的精力,现在上下班都开始步行.人生就是一场马拉松,无论何时何地都得学会享受好生活.每天早晚4公里的步行健身,晚上适当的跑步.看书.电视剧.音乐电台,整个人也感觉充实成长了好多.心静了,自信了,才能安宁,才能做好每一件事情.年后的这段期间做了一个公司自己的社交项目,总得来说学到很多,另外两

Vue教程02(跑马灯效果案例) 𽳜

原文: http://blog.gqylpy.com/gqy/423 置顶:来自一名75后老程序员的武林秘籍--必读(博主推荐) 来,先呈上武林秘籍链接:http://blog.gqylpy.com/gqy/401/ 你好,我是一名极客!一个 75 后的老工程师! 我将花两分钟,表述清楚我让你读这段文字的目的! 如果你看过武侠小说,你可以把这个经历理解为,你失足落入一个山洞遇到了一位垂暮的老者!而这位老者打算传你一套武功秘籍! 没错,我就是这个老者! 干研发 20 多年了!我也年轻过,奋斗过!我

练习:WinForm 跑马灯效果+Timer

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Timer { public partial class Form1 : Form { public Form1

Android TextView跑马灯效果

TextView跑马灯简单效果 <!--简单示例--> <TextView android:text="@string/longWord" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textView1" android:ellipsize="marquee&quo

android 怎么实现跑马灯效果

自定义控件 FocusedTextView, 使android系统误以为它拥有焦点 1 public class FocusedTextView extends TextView { 2 public FocusedTextView(Context context, AttributeSet attrs, int defStyle) { 3 super(context, attrs, defStyle); 4 // TODO Auto-generated constructor stub 5 }

框架,锚点,背景音乐,嵌入视频和跑马灯效果

框架,iframe有点过时,会在部分浏览器出现一些奇怪的问题:设置三个属性: 1.src,框架默认的显示路径 2.name,让超链接的target属性与name值相等,就可以将超链接网页在框架中打开 3.框架的宽度和高度 站点:实际上就是一个文件夹,单独起了一个名字.统一来管理所有页面,就是一个站点,称之为网站 锚点: 书写格式:<a href="#锚点位置对应的名称">内容</a> --#是在本页面中 <a name="锚点位置的名称"

jCarousel Lite 实现图片跑马灯效果

官方网站:http://www.gmarwaha.com/jquery/jcarousellite/ demo: <!DOCTYPE> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script src="http://libs.baidu.com/jquery/1.9.0/jquer

Android界面(1) 使用TextView实现跑马灯效果

方法一:(只能实现单个TextView的跑马灯效果)在TextView添加以下控件 android:singleLine="true"只能单行,超出的文字显示为"..." android:ellipsize="marquee"省略号没有,但没有跑马灯效果 android:focusable="true" android:focusableInTouchMode="true" 方法二:(可以实现多行TextV