代码之家  ›  专栏  ›  技术社区  ›  Michael D. Irizarry

有没有一个iphone复选框列表控件没有在google中列出?

  •  0
  • Michael D. Irizarry  · 技术社区  · 14 年前

    我有一个演示工作,但我想知道是否已经有一个像3p20这样的图书馆来与这种控制。

    这就是我现在所拥有的。它还没有重构。

    -

     (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;
    
     }
    
    }
    
    1 回复  |  直到 14 年前
        1
  •  3
  •   rpetrich    14 年前

    UITableView 在细胞中 accessoryType 设置为 UITableViewCellAccessoryCheckmark iphone是这种风格的标准吗