Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created April 10, 2013 16:00
Show Gist options
  • Save jcromartie/5355959 to your computer and use it in GitHub Desktop.
Save jcromartie/5355959 to your computer and use it in GitHub Desktop.
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
[titleLabel setNumberOfLines:0];
[titleLabel setLineBreakMode:NSLineBreakByWordWrapping];
[titleLabel setFont:[USNTheme smallTitleFont]];
[self addSubview:titleLabel];
[self setTitleLabel:titleLabel];
UILabel *summaryLabel = [[UILabel alloc] initWithFrame:CGRectZero];
[summaryLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
[summaryLabel setNumberOfLines:0];
[summaryLabel setLineBreakMode:NSLineBreakByWordWrapping];
[summaryLabel setFont:[USNTheme smallTextFont]];
[self addSubview:summaryLabel];
[self setSummaryLabel:summaryLabel];
NSDictionary *views = NSDictionaryOfVariableBindings(titleLabel, summaryLabel);
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-[titleLabel]-|"
options:nil
metrics:nil
views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-[summaryLabel]-|"
options:nil
metrics:nil
views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[titleLabel]-[summaryLabel]"
options:nil
metrics:nil
views:views]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment