-(void) layoutGrid {
UIColor *c3;
UIScrollView *sc=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 480, 320)];
sc.userInteractionEnabled=YES;
sc.backgroundColor=[UIColor purpleColor];
sc.delegate=self;
sc.scrollEnabled=YES;
sc.contentSize=CGSizeMake(1000,800);
[self.view addSubview:sc];
NSInteger grid[20][20];
NSInteger k = 0;
for (int row = 0; row <10; row++) {
for (int column = 0; column <20; column++) {
if(column%2==0){
c3=[UIColor blackColor];
}
else{
c3=[UIColor whiteColor];
}
k++;
grid[row][column] = k;
UIView *lbl = [[UIView alloc] initWithFrame:CGRectMake(column*50, row * 50, 40, 40)];
[lbl setBackgroundColor:c3];
[sc addSubview:lbl];
sc.userInteractionEnabled=YES;
}
}
}
No comments:
Post a Comment