在ui学习,用简单地uiView和视图控制器制作的霓虹灯效果,在这个过程中要学会使用定时器NSTimer的开启与关闭,这个是实现动态效果的关键一步,在使用时可以查看API文档查看,也可以上网查询;

初始化
+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo;

  • (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo;
 //开启定时器[_timer setFireDate:[NSDate distantPast]];
  //暂停定时器[_timer invalidate];

这里timer的内存并没有释放,如果释放了可能造成程序崩溃,这是我现在没有解决的

(http://img.blog.csdn.net/20151121174843569)
- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view.//布局子视图for (int i = 0; i < 10; i ++) {UIView *view = [[UIView alloc] initWithFrame:CGRectMake ( 15 +15*(i + 1), 15 * (i +1), 300 - i * 30, 600 -i *30 )] ;[self.view addSubview:view];view.backgroundColor = [UIColor colorWithRed:KColorKey green:KColorKey blue:KColorKey alpha:1.0];view.tag = 100 + i;[view release];}//添加按钮UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];btn.frame = CGRectMake(80, 620, 80, 40);btn.backgroundColor = [UIColor greenColor];[btn setTitle:@"开始" forState:UIControlStateNormal];[btn addTarget:self action:@selector(begin:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn];UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeSystem];btn1.frame = CGRectMake(180, 620, 80, 40);btn1.backgroundColor = [UIColor greenColor];[btn1 setTitle:@"取消" forState:UIControlStateNormal];[btn1 addTarget:self action:@selector(stop:) forControlEvents:UIControlEventTouchUpInside];[self.view addSubview:btn1];}//开始事件
- (void)begin: (UIButton *)btn {//添加定时器_timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(fromout) userInfo:nil repeats:YES];//开启定时器[_timer setFireDate:[NSDate distantPast]];}
//实现事件
//从里向外
- (void)fromout {UIColor *tem = [self.view viewWithTag:100].backgroundColor;for (int i = 100; i < 110; i ++) {[self.view viewWithTag:i].backgroundColor = [self.view viewWithTag:i+ 1].backgroundColor;}[self.view viewWithTag:100 + 9].backgroundColor = tem;//从外向里//    UIColor *temp = [self.view viewWithTag:100 + 9].backgroundColor;//    for (int i = 100 + 9; i >= 100; i--) {//        [self.view viewWithTag:i].backgroundColor = [self.view viewWithTag:i-1].backgroundColor;//    }//    [self.view viewWithTag:100].backgroundColor = temp;}
- (void)stop: (UIButton*) btn {//暂停定时器[_timer invalidate];}
@end

七彩霓虹灯 制作相关推荐

  1. android 霓虹灯制作

    1.霓虹灯 霓虹灯的主要制作是通过颜色在每个视图中的循环显示. 首先需要两个数组来分别定义颜色和视图 int[] colors=new colors[]{ Color.BLUE,Color.GREEN ...

  2. android控件字体,android 设置控件的颜色字体的方法

    1.用代码设置控件的颜色: int b =  getResources().getColor(R.drawable.blue);//得到配置文件里的颜色 mButton.setTextColor(b) ...

  3. 你明明是我师父,却偏要做我女朋友

    文 | 原西琦 01. 2015年年末,白欢喜断绝了与所有人的联系,一个人跑到了墨尔本. 她像是忘记了这几年国内发生的一切悲与欢,一个人在异地他乡尽情享受着晨光散落,流云飞走的好光景. 可这份淡然却被 ...

  4. 图片复印如何去除黑底_如何用AE制作可爱漂亮闪烁霓虹灯效果?只需简单几步任何人都可以...

    HELLO 大家好,亲们很久不见甚是想念!我是分享AEC4D手机特效小知识的乐乐,今后会定期持续分享一些AE小特效,C4D操作,手机特效,PS修图的原创教程内容,虽然可能只值5毛钱噢,只愿能为大家闲暇 ...

  5. 霓虹灯潮流时尚视频制作AE模板素材

    霓虹灯潮流时尚视频制作AE模板素材 非常适合介绍未来时尚频道.未来游戏促销或cosplay活动的杰出开场. 该AE模板的主要思想是在霓虹灯城市.魅力派对或激情舞蹈中营造一种夜生活氛围.霓虹未来时尚模板 ...

  6. 怎么把ppt文字大小设置一致_学会这个方法,轻松制作海报级别的霓虹灯PPT!

    大家好,我是A君,分享越多,快乐越多. 前段时间,有好几个客户需要定制双十一的活动策划PPT,所以特意在网上搜索了很多关于双十一的设计素材,其中霓虹灯设计风格特别引人注目. 每当看到漂亮的设计效果,第 ...

  7. Photoshop CS2 视频教程-PS制作霓虹灯效果(转)

    Photoshop CS2 视频教程-PS制作霓虹灯效果(转)[@more@] Photoshop CS2是Photoshop最新版本,也是目前图像处理功能最强大的软件之一.在教程安排上注重由浅入深, ...

  8. java制作霓虹灯_PS进阶教程!教你打造效果超逼真的动态闪烁霓虹灯

    编者按:很久没发动态教程,今天来一篇效果特别酷炫的,手把手教你打造迷蒙漂亮的闪烁霓虹灯效果.教程详尽易懂,光影得当,作为GIF效果的入门教程非常不错,强烈推荐 >>> 背景图素材(另 ...

  9. html5显示状态灯,如何使用css3+html5来制作文字霓虹灯效果

    使用css3+html5来制作文字霓虹灯效果的特点 文字带有闪烁的霓虹灯动画,且文字选中时也有很酷的动画特效: 文字可动态输入,且输入的文字实时渲染霓虹灯特效. 使用css3+html5来制作文字霓虹 ...

最新文章

  1. perl学习之(not install YAML)解决
  2. 为了今年印象最深刻的唱片,转演唱会消息一个,虽然我去不了 55555
  3. 序列化类型 System.Data.Entity.DynamicProxies 的对象时检测到循环引用
  4. 毕业后两三月的本科毕业生,他们都怎么样了
  5. Warning:关于_CRT_SECURE_NO_WARNINGS
  6. 数据装载器连接其他oracle数据库_07
  7. 控制窗口不能拖拉出主窗口 Dialog And Window
  8. 小希的迷宫(请永远相信c语言的强大)
  9. win7 linux启动设置u盘启动,在linux下怎么样制作win7的U盘启动?
  10. ActiveMQ 持久化
  11. 【笔记】如何把GBK的文本格式转换为UTF-8格式
  12. 【Matlab绘图进阶第2弹】Matlab绘制论文柱状图
  13. Altium Designer 18 导线转换45°的快捷键
  14. 1162开放英语4 (2)
  15. mysql 关联查询
  16. Jackson注解:@JsonAlias使用详解
  17. open failed: EACCES (Permission denied)解决办法
  18. Servlet的四个生命周期
  19. additional-methods.js 用法
  20. 从Google离职了。。。

热门文章

  1. Linux中Python应用CPU占用高问题排查
  2. vue微信支付业务生成二维码qrcode
  3. 做什么运动可以排毒养颜
  4. php将数组转化成json字符串,php数组如何转换json字符串
  5. Pinpoint详解(分布式链路追踪、链路监控)
  6. echarts进阶--销售趋势图
  7. 魅族魅蓝A5完美打开Usb调试模式的方法
  8. matplotlib 配色
  9. echarts里的seriesIndex 和dataIndex是什么意思
  10. 平方数及其相关思想(SDUT)