关灯游戏
来源:互联网 发布:阿里云域名icp备案 编辑:程序博客网 时间:2024/04/27 17:21
#import "mainViewController.h"
@interface mainViewController ()
@end
@implementation mainViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++) {
UIButton *button = [UIButtonbuttonWithType:UIButtonTypeSystem];
button.frame = CGRectMake(15 + 50 * i, 40 + 50 * j, 40, 40);
button.backgroundColor = [UIColor whiteColor];
[self.view addSubview:button];
button.tag = 10 * i + j + 1;
[button addTarget:self action:@selector(buttonAction:)forControlEvents:UIControlEventTouchUpInside];
}
}
}
- (void)buttonAction:(UIButton *)button
{
if (button.backgroundColor == [UIColor whiteColor]) {
button.backgroundColor = [UIColor blackColor];
NSInteger a = button.tag;
UIButton *button0 = (UIButton *)[self.view viewWithTag:(a - 1)];
if (button0.backgroundColor == [UIColor whiteColor]) {
button0.backgroundColor = [UIColor blackColor];
} else if (button0.backgroundColor == [UIColor blackColor]) {
button0.backgroundColor = [UIColor whiteColor];
}
UIButton *button1 = (UIButton *)[self.view viewWithTag:(a + 1)];
if (button1.backgroundColor == [UIColor whiteColor]) {
button1.backgroundColor = [UIColor blackColor];
} else if (button1.backgroundColor == [UIColor blackColor]) {
button1.backgroundColor = [UIColor whiteColor];
}
UIButton *button2 = (UIButton *)[self.view viewWithTag:(a - 10)];
if (button2.backgroundColor == [UIColor whiteColor]) {
button2.backgroundColor = [UIColor blackColor];
} else if (button2.backgroundColor == [UIColor blackColor]) {
button2.backgroundColor = [UIColor whiteColor];
}
UIButton *button3 = (UIButton *)[self.view viewWithTag:(a + 10)];
if (button3.backgroundColor == [UIColor whiteColor]) {
button3.backgroundColor = [UIColor blackColor];
} else if (button0.backgroundColor == [UIColor blackColor]) {
button3.backgroundColor = [UIColor whiteColor];
}
} else if (button.backgroundColor == [UIColor blackColor]) {
button.backgroundColor = [UIColor whiteColor];
NSInteger a = button.tag;
UIButton *button0 = (UIButton *)[self.view viewWithTag:(a - 1)];
if (button0.backgroundColor == [UIColor whiteColor]) {
button0.backgroundColor = [UIColor blackColor];
} else if (button0.backgroundColor == [UIColor blackColor]) {
button0.backgroundColor = [UIColor whiteColor];
}
UIButton *button1 = (UIButton *)[self.view viewWithTag:(a + 1)];
if (button1.backgroundColor == [UIColor whiteColor]) {
button1.backgroundColor = [UIColor blackColor];
} else if (button1.backgroundColor == [UIColor blackColor]) {
button1.backgroundColor = [UIColor whiteColor];
}
UIButton *button2 = (UIButton *)[self.view viewWithTag:(a - 10)];
if (button2.backgroundColor == [UIColor whiteColor]) {
button2.backgroundColor = [UIColor blackColor];
} else if (button2.backgroundColor == [UIColor blackColor]) {
button2.backgroundColor = [UIColor whiteColor];
}
UIButton *button3 = (UIButton *)[self.view viewWithTag:(a + 10)];
if (button3.backgroundColor == [UIColor whiteColor]) {
button3.backgroundColor = [UIColor blackColor];
} else if (button3.backgroundColor == [UIColor blackColor]) {
button3.backgroundColor = [UIColor whiteColor];
}
}
NSLog(@"%d", button.tag);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- IOS 关灯游戏
- 关灯游戏无限关
- 关灯游戏源代码
- ios关灯游戏源代码
- UI关灯游戏 代码
- OC关灯游戏
- UITouchView实现关灯游戏
- IOS UI 关灯游戏
- 关灯游戏代码
- 用爱绑架他人?
- 常用图
- [老欧的问题]如何在应用内使用adb命令[待优化]
- 使用Spring跟踪应用异常(2)—委托模式
- 四种常见的 POST 提交数据方式
- 关灯游戏
- linux系统下修改文件夹目录权限
- 毕业季,我毕业了
- OCP 1Z0 052 140
- eclipse Windowbuilder程序打包
- 点滴记录——在Ubuntu 14.04中使SublimeText 3支持中文输入法
- #if 1 #elseif0 #endif用法
- Linux串口编程详解
- DIODES(达尔科技)样片申请与经验