我有一个演示工作,但我想知道是否已经有一个像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;
}
}