Skip to content

Instantly share code, notes, and snippets.

@rdeguzman
Created March 4, 2011 05:00
Show Gist options
  • Save rdeguzman/854197 to your computer and use it in GitHub Desktop.
Save rdeguzman/854197 to your computer and use it in GitHub Desktop.
#define PADDING_VERTICAL 5.0f
#define BUTTON_HEIGHT 40.0f
#define BUTTON_WIDTH 160.0f
#define BUTTON_ORIGIN_X (320.0f - BUTTON_WIDTH)/2.0f
#define BUTTON_ORIGIN_Y 20.0f
- (void)initButtons{
NSLog(@"MainViewController.initButtons");
CGFloat totalHeight = BUTTON_ORIGIN_Y;
for(NSDictionary* section in arraySections){
NSString* title = [section objectForKey:@"title"];
UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchDown];
[button setTitle:title forState:UIControlStateNormal];
button.frame = CGRectMake(BUTTON_ORIGIN_X, totalHeight, BUTTON_WIDTH, BUTTON_HEIGHT);
[self.view addSubview:button];
totalHeight = totalHeight + BUTTON_HEIGHT + PADDING_VERTICAL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment