关灯
来源:互联网 发布:网络面具骚彤彤搭档 编辑:程序博客网 时间:2024/04/27 20:54
//
// CloseLightController.m
// UI_2_HomeWork
//
// Created by 0101 on 13-7-26.
// Copyright (c) 2013年 PH. All rights reserved.
//
#import "CloseLamp.h"
#define KFrame(x,y,w,h) CGRectMake(x,y,w,h)
@implementation CloseLamp
-(void)loadView
{
self.view = [[[UIViewalloc]initWithFrame:KFrame(0,0, 320,480)]autorelease];//初始化根视图 或者[super alloc]
self.view.backgroundColor = [UIColororangeColor];
int k = 1;
for (int i =0; i < 4; i++)
{
for (int j =0; j < 4; j++)
{
UIButton *btn = [UIButtonbuttonWithType:UIButtonTypeCustom];
btn.frame =KFrame(i*65+10, j*65+10,60, 60);
btn.backgroundColor = [UIColorwhiteColor];
btn.tag =1000+k;
[btn addTarget:selfaction:@selector(changeStatus:)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:btn];
k++;
}
}
}
-(void)changeStatus:(UIButton *)sender
{
[selfchangeColor:sender];//当前按钮改变颜色
//左按钮
if (sender.tag %4 != 1)
{
UIButton *btnLeft = (UIButton *)[self.viewviewWithTag:sender.tag -1];
[selfchangeColor:btnLeft];
}
//右按钮
if (sender.tag %4 != 0)
{
UIButton *btnRight = (UIButton *)[self.viewviewWithTag:sender.tag +1];
[selfchangeColor:btnRight];
}
//上按钮
UIButton *btnUp = (UIButton *)[self.viewviewWithTag:sender.tag -4];
[selfchangeColor:btnUp];
//下按钮
UIButton *btnBelow = (UIButton *)[self.viewviewWithTag:sender.tag +4];
[selfchangeColor:btnBelow];
}
-(void)changeColor:(UIButton *)sender
{
if (sender.backgroundColor == [UIColorwhiteColor])
{
sender.backgroundColor = [UIColorblackColor];
}
else
{
sender.backgroundColor = [UIColorwhiteColor];
}
}
-(void)viewDidLoad
{
}
-(void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
}
@end
- 关灯
- 关灯游戏
- 囚犯关灯
- 关灯问题
- 关灯问题
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 趣味关灯
- 关灯问题
- 关灯游戏
- 关灯小游戏
- 关灯问题
- Andriod 闪关灯问题解决
- 【分享】一款手机真机屏幕同步抓取软件
- Javascript中Function,Object,Prototypes,__proto__等概念详解
- hdu 1867
- 【Windows 8系统开始添加关机按钮教程】
- 浅谈 SIM-OTA
- 关灯
- Android基于XMPP Smack Openfire开发IM【三】客户端接收服务器发送的消息
- hdu
- 从实时模式到保护模式之二
- Sicily 1790. Single Round Match
- 初来乍到
- 移植boa到TQ2440网页LED实现
- uva 123 Searching Quickly(遍历+排序)
- 匹配前一个字符一次或多次