views:

260

answers:

1

I have a demo working but I was wondering if there is already a library like Three20 that comes with this sort of control.

This is what I have till now. It's not refactored yet.

-

 (void)viewDidLoad {
    [super viewDidLoad];

 // Gets Types
 [self getTypes];

 // Set Guilt Types UI
 CGFloat kTopMargin = 160.0;
 CGFloat kTopMarginSpan = 30.0;

 NSEnumerator *enumerator = [TypesArray objectEnumerator];
    id obj;

    while ( obj = [enumerator nextObject] ) {

  CGSize fontSize = [[obj name] sizeWithFont:[UIFont systemFontOfSize:22.0]];

  UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, kTopMargin, fontSize.width, 25.0)];
  aLabel.font = [UIFont fontWithName:@"Helvetica" size:22.0];
  aLabel.adjustsFontSizeToFitWidth = YES;
  aLabel.highlightedTextColor = [UIColor blackColor];
  aLabel.textAlignment = UITextAlignmentCenter; 
  aLabel.textColor = [UIColor colorWithRed:168/255.0 green:16/255.0 blue:16/255.0 alpha:1.0]; 
  aLabel.backgroundColor = [UIColor clearColor];
  aLabel.text = [obj name];
  [self.view addSubview:aLabel];
  [aLabel release];

  UIButton *aButton = [[UIButton alloc] initWithFrame:CGRectMake(fontSize.width + 10.0, kTopMargin + 5, 16.0, 16.0)];
  [aButton setBackgroundImage:[[UIImage imageNamed:@"checkbox.png"] stretchableImageWithLeftCapWidth: 12.0 topCapHeight: 0.0] forState:UIControlStateNormal];
  [aButton setBackgroundImage:[[UIImage imageNamed:@"chechbox-checked.png"] stretchableImageWithLeftCapWidth: 12.0 topCapHeight: 0.0] forState:UIControlStateSelected];
  [aButton setBackgroundImage:[[UIImage imageNamed:@"chechbox-pressed.png"] stretchableImageWithLeftCapWidth: 12.0 topCapHeight: 0.0] forState:UIControlStateHighlighted];
  [aButton setBackgroundColor:[UIColor clearColor]];
  aButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
  aButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
  [self.view addSubview:aButton];
  [aButton release];

  kTopMargin = kTopMargin + kTopMarginSpan;

 }

}
+2  A: 

A UITableView with cells that have their accessoryType set to UITableViewCellAccessoryCheckmark is the iPhone standard for this style

rpetrich
I know but I have my own UI, that's why I want a custom checkbox list so I can have my own check marks without relying on the iPhones UI.
JeremySpouken
If you're making a table-styled view, `UITableView` (and company) is definitely the way to go. Don't reinvent the wheel. If you just want custom styled checkboxes, simply create your own `UIImageView` and assign it to the `accessoryView` property.
rpetrich