Last active
January 3, 2016 16:08
-
-
Save steveriggins/8486943 to your computer and use it in GitHub Desktop.
Simple label in a viewController's view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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