刚学ui,自己写了个霓虹灯,我觉的我写的这个比比百度上简单多了!!!
来源:互联网 发布:八皇后问题递归算法 编辑:程序博客网 时间:2024/04/27 16:46
//先生成霓虹灯框架,同时为其随机附上不同的颜色
for (int i = 0; i < 7; i++) {
CGRect frame = CGRectMake(0 + 30 * i, 100 + 30 * i, 375 - 30 * 2 * i, 375 - 30 * i * 2);
UIView *view = [[UIView alloc] initWithFrame:frame];
view.tag = 100 + i;
view.backgroundColor = [UIColor colorWithRed:arc4random() % 255 / 255.0 green:arc4random() % 255 / 255.0 blue:arc4random() % 255 / 255.0 alpha:1.0];
[self.window addSubview:view];
[view release];
}
//从里到外
[self insideToOutside];
//从外道里
[self outsideToInside];
//写从里到外的方法
//生成按钮
- (void)insideToOutside {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];btn.frame = CGRectMake(50, 525, 100, 40);btn.backgroundColor = [UIColor redColor];[btn setTitle:@"从里到外" forState:UIControlStateNormal];[btn addTarget:self action:@selector(toout:) forControlEvents:UIControlEventTouchUpInside];[self.window addSubview:btn];}
//颜色从里到外, 上面我自己附的tag值是100-106,所有遍历的是100-106,
让当前的颜色被后一个替代.到了最后一个时,再随机生成一种颜色.
- (void)toout:(UIButton *)sender {
for (int i = 100; i < 107; i ++) {
[self.window viewWithTag:i].backgroundColor = [self.window viewWithTag:i + 1].backgroundColor;
[self.window viewWithTag:106].backgroundColor = [UIColor colorWithRed:arc4random() % 255 / 255.0 green:arc4random() % 255 / 255.0 blue:arc4random() % 255 / 255.0 alpha:1.0];
}
}
//从外到里
- (void)outsideToInside {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];btn.frame = CGRectMake(200, 525, 100, 40);btn.backgroundColor = [UIColor redColor];[btn setTitle:@"从外到里" forState:UIControlStateNormal];[btn addTarget:self action:@selector(toinside:) forControlEvents:UIControlEventTouchUpInside];[self.window addSubview:btn];
}
//变化方法同上,只需要注意替换位置就行.
- (void)toinside:(UIButton *)sender {
for (int i = 107; i >= 100; i –) {
[self.window viewWithTag:i].backgroundColor = [self.window viewWithTag:i - 1].backgroundColor;
[self.window viewWithTag:100].backgroundColor = [UIColor colorWithRed:arc4random() % 255 / 255.0 green:arc4random() % 255 / 255.0 blue:arc4random() % 255 / 255.0 alpha:1.0];
}
}
- 刚学ui,自己写了个霓虹灯,我觉的我写的这个比比百度上简单多了!!!
- 从现在起 我开始写我自己的技术博客了
- 好久没有写博客了,写一下刚学的
- makefile太难了,学不会,自己用Python写个简单的构建工具
- 小朋友在我的启发下自己写了个select的联动相关的东西
- 刚学JavaSE,自己写了一个学生的抽号小小系统。。。。
- 我终于可以写自己的blog了
- 终于开始写我自己的BLOG了
- 经过了试用期,我自己写的述职报告
- 我自己也写了一个八皇后的程序
- 今天开始我写我的博客了。主要写自己的累积
- 学了2天的Python,自己写了个简单的爬虫,可是爬虫有什么用呢?
- 刚学数据结构,写了个C语言栈的头文件方便新手一块用~
- 自己写了个简单的供求系统
- 我想写的程序(走题了哦,不过我已经原谅我自己了:)
- 我又写了个空心的等边三角形
- 新写机器猫游戏,国内写机器猫游戏的不多,所以我这个是原创了,呵呵(图)
- 我自己写的第一个控件
- 用lag补满数据
- 关于在Editplus中设置内容提示比如syso的快捷输出的方法
- 《UNIX编程艺术》精彩语录
- Struts2入门:struts2环境配置和一个小例子
- 游戏中汉字显示的实现与技巧
- 刚学ui,自己写了个霓虹灯,我觉的我写的这个比比百度上简单多了!!!
- 怎样编写一个类Spy++的搜索窗口程序
- QueryPerformanceFrequency用法--Windows高精度定时计数
- 如何利用开发者账号重签ipa文件,并部署到IOS设备做测试
- 希望获得一个前辈的腾讯2016校园招聘TST内推---- C++研发
- weiphp_sae 图片无法上传 错误‘./uploads/picture
- android开发笔记之Volley (1)
- USACO Barn Repair(greedy)
- 创建Entitlements文件与编译iOS APP