UI控件闪灯
做出点一个控件然后他和他上下左右的4个控件一起变色。
#import "ViewController.h"
@interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
//每个方块的高度和宽度
CGFloat width=50 ;
CGFloat height=50;
//列数
int lie=5;
//一行之中的方块间隙
CGFloat Xjianxi=(self.view.frame.size.width-width*lie)/(lie +1);
//一列之中的方块间隙
CGFloat Yjianxi=30;
self.number=1;
//循环,
for (int i=0; i<45; i++) {
int hangshu=i/lie;
int lieshu=i%lie;
self.butn=[[UIButton alloc]initWithFrame:CGRectMake(Xjianxi+lieshu*(Xjianxi+width), Yjianxi+hangshu*(height+Yjianxi), width, height)];
self.butn.backgroundColor=[UIColor blueColor];
self.view.tag=100; [self.butn addTarget:self action:@selector(Discoloration:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.butn];
self.butn.tag=self.number++; } } -(void)change
{
if (self.backgroundColor==[UIColor redColor]) {
self.backgroundColor=[UIColor blueColor];
}
else{
self.backgroundColor=[UIColor redColor];
}
} -(void)Discoloration:(UIButton*)btn
{
// [[self.view viewWithTag:btn.tag] change];
// [[self.view viewWithTag:btn.tag-1] change];
// [[self.view viewWithTag:btn.tag+1] change];
// [[self.view viewWithTag:btn.tag+5] change];
// [[self.view viewWithTag:btn.tag-5]change];
self.butn=btn; if (self.butn.tag==1) {
[[self.view viewWithTag:btn.tag ] change];
[[self.view viewWithTag:btn.tag+1] change];
[[self.view viewWithTag:btn.tag+5] change];
}
else if(self.butn.tag==5)
{
[[self.view viewWithTag:btn.tag] change];
[[self.view viewWithTag:btn.tag-1] change];
[[self.view viewWithTag:btn.tag+5] change];
}
else if(self.butn.tag==41)
{
[[self.view viewWithTag:btn.tag] change];
[[self.view viewWithTag:btn.tag-5] change];
[[self.view viewWithTag:btn.tag+1] change];
}
else if(self.butn.tag==45)
{
[[self.view viewWithTag:btn.tag] change];
[[self.view viewWithTag:btn.tag-1] change];
[[self.view viewWithTag:btn.tag-5] change];
}
else if(self.butn.tag%5==1)
{
[[self.view viewWithTag:btn.tag] change];
[[self.view viewWithTag:btn.tag-5] change];
[[self.view viewWithTag:btn.tag+1] change];
[[self.view viewWithTag:btn.tag+5] change];
}
else if(self.butn.tag%5==0)
{
[[self.view viewWithTag:btn.tag] change];
[[self.view viewWithTag:btn.tag-5] change];
[[self.view viewWithTag:btn.tag-1] change];
[[self.view viewWithTag:btn.tag+5] change];
}
else if(self.butn.tag%5==1)
{
[[self.view viewWithTag:btn.tag] change];
[[self.view viewWithTag:btn.tag-5] change];
[[self.view viewWithTag:btn.tag+1] change];
[[self.view viewWithTag:btn.tag-5] change];
}
else
{
[[self.view viewWithTag:btn.tag] change];
[[self.view viewWithTag:btn.tag-1] change];
[[self.view viewWithTag:btn.tag+1] change];
[[self.view viewWithTag:btn.tag-5] change];
[[self.view viewWithTag:btn.tag+5] change];
}
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
UI控件闪灯的更多相关文章
- ANDROID L——Material Design详解(UI控件)
转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! Android L: Google已经确认Android L就是Android Lolli ...
- WinForm/Silverlight多线程编程中如何更新UI控件的值
单线程的winfom程序中,设置一个控件的值是很easy的事情,直接 this.TextBox1.value = "Hello World!";就搞定了,但是如果在一个新线程中这么 ...
- 富客户端 wpf, Winform 多线程更新UI控件
前言 在富客户端的app中,如果在主线程中运行一些长时间的任务,那么应用程序的UI就不能正常相应.因为主线程要负责消息循环,相应鼠标等事件还有展现UI. 因此我们可以开启一个线程来格外处理需要长时间的 ...
- UI控件(复习一下)
如何修改控件状态• 可见,确实需要经常修改控件状态• 那如何去修改控件的状态呢?方法很简单➢ 每一个UI控件都是一个对象➢ 修改UI控件的状态,其实就是修改控件对象的属性➢ 比如修改UILabel显示 ...
- IOS学习资源收集--开发UI控件相关
收集的一些本人了解过的iOS开发UI控件相关的代码资源(本文持续补充更新) 内容大纲: 1.本人在github上也上传了我分装好的一些可重复利用的UI控件 2.计时相关的自定义UILabel控件 正文 ...
- 《深入理解Windows Phone 8.1 UI控件编程》基于最新的Runtime框架
<深入理解Windows Phone 8.1 UI控件编程>本书基于最新的Windows Phone 8.1 Runtime SDK编写,全面深入地论述了最酷的UI编程技术:实现复杂炫酷的 ...
- AppleWatch___学习笔记(二)UI布局和UI控件
1.UI布局 直接开发,你会发现Apple Watch并不支持AutoLayout,WatchKit里有个类叫做WKInterfaceGroup,乍一看像是UIView,但是这货其实是用来布局的.从 ...
- (转).NET 4.5中使用Task.Run和Parallel.For()实现的C# Winform多线程任务及跨线程更新UI控件综合实例
http://2sharings.com/2014/net-4-5-task-run-parallel-for-winform-cross-multiple-threads-update-ui-dem ...
- Atitit. .net c# web 跟客户端winform 的ui控件结构比较
Atitit. .net c# web 跟客户端winform 的ui控件结构比较 .net 4.5 webform Winform 命名空间 System.Web.UI.WebControls ...
随机推荐
- ASP.NET MVC怎样引用你的model
在视图中,引用model,并绑定.有2种情况,一是数据集,另一个是单个model. 实现之前,有准备一个数据吧. 创建一个model: source code: namespace Insus.NET ...
- Castle ActiveRecord框架学习(二):快速搭建简单博客网站
一.数据库 1.数据表 Category:类别标签表(字段Type=1为类别,Type=2为标签) Category_Post:类别标签与文章中间表 Post:文章表 Comment:评论表 2.数据 ...
- 关于SilverLight
目前工作中用到SilverLight,有必要对其作一定的了解.
- 【Java每日一题】20161206
package Dec2016; public class Ques1206 { public static void main(String[] args){ doSex(null); } publ ...
- oracle分组查询实例ORA-00979和ORA-00937错误分析
select J.ZWJGH,J.CZZXBH,J.JZZT,J.CWNY,J.JZPZH sum(J.FSE)<!-- 聚合函数字段没在分组条件中--> from JZPZXX J &l ...
- 第 19 章 CSS 其他样式
学习要点: 1.颜色和透明度 2.盒子阴影和轮廓 3.光标样式 主讲教师:李炎恢 本章主要探讨 HTML5 中 CSS 其他剩下几个常用的样式,包括颜色.透明度.盒子的阴影轮廓以及光标的样式. 一.颜 ...
- quickstart.sh
#!/bin/bashjava_pid=`ps -ef | grep java | grep 'com.kzhong.huamu.sisyphus.QuickStartServer' | awk '{ ...
- [小北De编程手记] : Lesson 02 玩转 xUnit.Net 之 基本UnitTest & 数据驱动
关于<玩转 xUnit.Net>系列文章,我想跟大家分享的不是简单的运行一下测试用例或是介绍一下标签怎么使用(这样的文章网上很多).上一篇<Lesson 01 玩转 xUnit.Ne ...
- JProfiler 8下载地址和注册码
JProfiler---- 一个很好的java性能监控工具,现在附上下载地址和注册码,此破解版仅供学习交流使用, 其他用途请购买正版授权!!!windows x64 zip下载地址:http://do ...
- .Net中的并行编程-5.流水线模型实战
自己在Excel整理了很多想写的话题,但苦于最近比较忙(其实这是借口).... 上篇文章<.Net中的并行编程-4.实现高性能异步队列>介绍了异步队列的实现,本篇文章介绍我实际工作者遇到了 ...