标签:io ar color sp for on div bs ad
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
int arr[4][4]={
1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1
};
NSMutableArray *varray=[[NSMutableArray alloc]init];//创建一个动态的数组
for (int i=0; i<16; i++) //在数组中有十六个方块
{
int row =i/4; //想要的数字在那一行
int column=i%4;//想要的数字在那一列
UIView *v=[[UIView alloc]initWithFrame:CGRectMake(column*54, row*54, 50, 50)]; //创建一个方块并把它用指针v来代替;创建后并设定了他的坐标
[varray addObject:varray];
[self.view addSubview:v];//在显示平面显示
}
for (int row=0; row<4; ++row)
{
for ( int column=0;column<4;++column)
{
UIView *v=varray[row*4+column];
if (arr[row][column])
{
v.backgroundColor=[UIColor redColor];
}
else{
v.backgroundColor=[UIColor clearColor];
}
}
}
标签:io ar color sp for on div bs ad
原文地址:http://www.cnblogs.com/daijiahong/p/4131824.html