A possible Objective-C version to create the labels looks pretty much the same to me anyway:
#define MSTR(...) [[NSString stringWithFormat:__VA_ARGS__] UTF8String]
@implementation LotsaLabels
- (id)initWithFrame:(CGRect)frame
{
if (self = [super init]) {
CGFloat offset = 0.0;
[@[@"label1", @"label2", @"label3", @"label4"] enumerateObjectUsingBlock:^ (id object, NSInteger idx, BOOL *stop) {
object_setInstanceVariable(self, MSTR(@"%@_text", object), [[UILabel alloc] initWithFrame:CGRectMake(0, 10 + offset, self.frame.size.width, 40)]);
object_setInstanceVariable(self, MSTR(@"%@_label", object), [[UILabel alloc] initWithFrame:CGRectMake(0, 55 + offset, self.frame.size.width, 14)]);
UILabel *text = object_getInstanceVariable(self, MSTR(@"%@_text", object));
UILabel *label = object_getInstanceVariable(self, MSTR(@"%@_label", object));
text.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:40];
text.textColor = [UIColor redColor];
label.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:15];
text.textColor = [UIColor grayColor];
text.text = label.text = [object capitalizedString];
text.adjustsFontSizeToFitWidth = label.adjustsFontSizeToFitWidth = YES;
text.backgroundColor = label.backgroundColor = [UIColor clearColor];
text.textAlignment = label.textAlignment = UITextAlignmentCenter;
[self addSubview:text];
[self addSubview:label];
offset += 90.0;
}];
}
return self;
}
@end
The Ruby version is slightly less verbose, I'll give him that, but many of the lines are nearly identical.