Skip to content

Instantly share code, notes, and snippets.

@steveriggins
Last active January 3, 2016 16:08
Show Gist options
  • Save steveriggins/8486943 to your computer and use it in GitHub Desktop.
Save steveriggins/8486943 to your computer and use it in GitHub Desktop.
Simple label in a viewController's view
- (void)viewDidLoad
{
[super viewDidLoad];
self.listPriceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
self.listPriceLabel.backgroundColor = [UIColor yellowColor];
[self.view addSubview:self.listPriceLabel];
[self.listPriceLabel sizeToFit];
self.listPriceLabel.text = @"Hello World";
NSDictionary *viewsDictionary = @{@"listPriceLabel": self.listPriceLabel};
NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-20-[listPriceLabel]"
options:0
metrics:nil
views:viewsDictionary];
[self.view addConstraints:constraints];
[self.view updateConstraintsIfNeeded];
// Do any additional setup after loading the view, typically from a nib.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment