#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];//Create a dynamic array
for (int i=0; i<16; i++)//16 blocks in the array
{
int row =i/4; The number you want is in that line.
int column=i%4;//want the number in that column
UIView *v=[[uiview Alloc]initwithframe:cgrectmake (column*54, row*54, 50, 50)]; Create a block and replace it with a pointer V, create and set his coordinates
[Varray Addobject:varray];
[Self.view addsubview:v];//in Display flat display
}
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];
}
}
}
Create a few small squares