I want to create view with 52 square or button (for 52 week in a year in one page) with grid but I don't know how should I align them or how should I put them in a frame
(you will have 13 rows and 4 columns), but if you try this code it's not algin : I don't know how should I create frame to put all of buttons in side of my frame..
Here is my code:
- (void)viewDidLoad
{
[super viewDidLoad];
int rows = 13, columns = 4;
for (int y = 0; y < rows; y++) {
for (int x = 0; x < columns; x++) {
UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(58 * x, 31 * y, 58, 31);
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview: button];
}
}
}
-(void)buttonPressed:(UIButton *)button
{
NSLog(@"button %u -- frame: %@", button.tag, NSStringFromCGRect(button.frame));
}