MASExampleLayoutGuideViewController.m
1.9 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
60
61
62
63
64
65
66
67
68
69
70
71
//
// MASExampleLayoutGuideViewController.m
// Masonry iOS Examples
//
// Created by Jonas Budelmann on 26/11/13.
// Copyright (c) 2013 Jonas Budelmann. All rights reserved.
//
#import "MASExampleLayoutGuideViewController.h"
@interface MASExampleLayoutGuideViewController ()
@end
@implementation MASExampleLayoutGuideViewController
- (id)init {
self = [super init];
if (!self) return nil;
self.title = @"Layout Guides";
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UIView *topView = UIView.new;
topView.backgroundColor = UIColor.greenColor;
topView.layer.borderColor = UIColor.blackColor.CGColor;
topView.layer.borderWidth = 2;
[self.view addSubview:topView];
UIView *topSubview = UIView.new;
topSubview.backgroundColor = UIColor.blueColor;
topSubview.layer.borderColor = UIColor.blackColor.CGColor;
topSubview.layer.borderWidth = 2;
[topView addSubview:topSubview];
UIView *bottomView = UIView.new;
bottomView.backgroundColor = UIColor.redColor;
bottomView.layer.borderColor = UIColor.blackColor.CGColor;
bottomView.layer.borderWidth = 2;
[self.view addSubview:bottomView];
[topView makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.mas_topLayoutGuide);
make.left.equalTo(self.view);
make.right.equalTo(self.view);
make.height.equalTo(@40);
}];
[topSubview makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.mas_topLayoutGuide);
make.centerX.equalTo(@0);
make.width.equalTo(@20);
make.height.equalTo(@20);
}];
[bottomView makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.mas_bottomLayoutGuide);
make.left.equalTo(self.view);
make.right.equalTo(self.view);
make.height.equalTo(@40);
}];
}
@end