Repository navigation
Expand file tree
/
Copy pathEVViewController.m
More file actions
59 lines (47 loc) · 1.64 KB
/
Copy pathEVViewController.m
File metadata and controls
59 lines (47 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// EVViewController.m
// AutoLayoutFun
//
// Created by Ethan Vaughan on 11/28/13.
// Copyright (c) 2013 Ethan James Vaughan. All rights reserved.
//
#import "EVViewController.h"
#import "NSLayoutConstraint+SimpleFormatLanguage.h"
@interface EVViewController ()
@end
@implementation EVViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIView *redView = [[UIView alloc] initWithFrame:CGRectZero];
redView.backgroundColor = [UIColor redColor];
redView.translatesAutoresizingMaskIntoConstraints = NO;
UIView *blueView = [[UIView alloc] initWithFrame:CGRectZero];
blueView.backgroundColor = [UIColor blueColor];
blueView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:redView];
[self.view addSubview:blueView];
UIView *superview = self.view;
[superview addConstraints:
[NSLayoutConstraint
constraintsWithSimpleFormat:
@[ @"redView.width = 100",
@"redView.height = redView.width",
@"redView.left = superview.left",
@"redView.centerY = superview.centerY",
@"blueView.height = 100",
@"blueView.centerY = superview.centerY",
@"blueView.left = redView.right + spacer",
@"blueView.right <= superview.right - 50",
@"blueView.width = 3 * redView.width @ 750" ]
metrics:@{ @"spacer" : @20 }
views:
NSDictionaryOfVariableBindings(redView, blueView, superview)]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end