基于Objective-C的iOS霓虹灯程序
来源:互联网 发布:node sass 安装 编辑:程序博客网 时间:2024/05/21 18:30
霓虹灯
基于OC实现的霓虹灯效果,看着有点刺眼。。。不过很好玩。
效果图:
你需要做的东西,就是用Xcode新建一个iOS工程,然后将下面代码敲上就可以实现。
代码如下:
UIView *yellow = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 375, 600)]; yellow.backgroundColor = [UIColor yellowColor]; yellow.center = CGPointMake((self.window.frame.size.width) / 2, (self.window.frame.size.height) / 2); yellow.tag = 1; [self.window addSubview:yellow]; [yellow release]; UIView *red = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 500)]; red.backgroundColor = [UIColor redColor]; red.center = CGPointMake((self.window.frame.size.width) / 2, (self.window.frame.size.height) / 2); red.tag = 2; [self.window addSubview:red]; [red release]; UIView *blue = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 225, 400)]; blue.backgroundColor = [UIColor blueColor]; blue.center = CGPointMake((self.window.frame.size.width) / 2, (self.window.frame.size.height) / 2); blue.tag = 3; [self.window addSubview:blue]; [blue release]; UIView *green = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 150, 300)]; green.backgroundColor = [UIColor greenColor]; green.center = CGPointMake((self.window.frame.size.width) / 2, (self.window.frame.size.height) / 2); green.tag = 4; [self.window addSubview:green]; [green release]; UIView *gray = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 75, 200)]; gray.backgroundColor = [UIColor grayColor]; gray.center = CGPointMake((self.window.frame.size.width) / 2, (self.window.frame.size.height) / 2); gray.tag = 5; [self.window addSubview:gray]; [gray release]; self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(change) userInfo:nil repeats:YES];
下面是一个方法:
- (void)change{ UIView *yellow = [self.window viewWithTag:1]; UIView *red = [self.window viewWithTag:2]; UIView *blue = [self.window viewWithTag:3]; UIView *green = [self.window viewWithTag:4]; UIView *gray = [self.window viewWithTag:5]; UIView *temp = [[UIView alloc] init]; temp.backgroundColor = yellow.backgroundColor; yellow.backgroundColor = red.backgroundColor; red.backgroundColor = blue.backgroundColor; blue.backgroundColor = green.backgroundColor; green.backgroundColor = gray.backgroundColor; gray.backgroundColor = temp.backgroundColor;}
应该就是这些了,基本的小东西,挺好玩的。
2 0
- 基于Objective-C的iOS霓虹灯程序
- iOS基于Objective-c的MD5/SHA1加密算法的实现
- 我对于iOS的KVO的理解基于Objective-C
- iOS clang编译Objective-C程序
- iOS之UI编程--霓虹灯的实现
- iOS之UI编程--霓虹灯的实现
- ios objective c 的基本知识
- 模拟霓虹灯滚动的c代码
- 基于Swift的iOS应用程序开发:创建Swift与Objective-C之间的桥接头文件
- 基于Objective-C的面向对象编程
- 基于 Objective-C 的中级通讯录代码
- ios霓虹灯效果(没基础也可以做出好看的霓虹灯)
- 黑马程序员——IOS基础---Objective-C第一节课---最简单的OC程序
- IOS 霓虹灯效果
- IOS 霓虹灯效果(oc)
- 一个最简单的Objective C 程序
- Objective-C的第一个程序
- 绘制Objective-C程序的UML类图
- Java三大框架
- [Unity热更新]lua基础(四)
- 求a,b两个数中较大的数
- Educational Codeforces Round 1(B)
- 带你玩转Visual Studio——Property Manager的配制
- 基于Objective-C的iOS霓虹灯程序
- Spark修炼之道(进阶篇)——Spark入门到精通:第七节 Spark运行原理
- 编译原理实验课反思之无知是一种罪
- 第32讲 实践项目——输出小星星2
- vim多行增加缩进
- 用qt creator,常量中有换行符的解决办法
- 2011 Asia ChengDu Regional Contest
- Tiny6410移植sqlite3
- 对象、原型、继承