-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathORFifthViewController.m
More file actions
122 lines (95 loc) · 4.72 KB
/
ORFifthViewController.m
File metadata and controls
122 lines (95 loc) · 4.72 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//
// ORFifthViewController.m
// ORStackViewExample
//
// Created by Laura Brown on 5/13/14.
// Copyright (c) 2014 Orta. All rights reserved.
//
#import "ORFifthViewController.h"
#import "ORColourView.h"
#import <ORStackView/ORSplitStackView.h>
#import <ORStackView/ORStackScrollView.h>
@interface ORFifthViewController ()
@property (nonatomic, strong) ORStackScrollView *view;
@end
@implementation ORFifthViewController
@dynamic view;
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
- (void)loadView
{
self.view = [[ORStackScrollView alloc] initWithStackViewClass:[ORStackView class]];
}
- (void)viewDidLoad
{
ORColourView *view1 = [[ORColourView alloc] init];
view1.text = @"Stack views can be nested inside stack views.";
view1.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 100};
ORColourView *view2 = [[ORColourView alloc] init];
view2.text = @"This is an ORStackScrollView containing an ORSplitStackView.";
view2.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 80};
ORColourView *view3 = [[ORColourView alloc] init];
view3.text = @"a view";
view3.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 50};
ORSplitStackView *view4 = [[ORSplitStackView alloc] initWithLeftPredicate:@"155" rightPredicate:@"130"];
view4.backgroundColor = [UIColor purpleColor];
ORColourView *view5 = [[ORColourView alloc] init];
view5.text = @"a view";
view5.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 50};
ORColourView *view6 = [[ORColourView alloc] init];
view6.text = @"a view";
view6.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 60};
ORColourView *view7 = [[ORColourView alloc] init];
view7.text = @"a view";
view7.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 50};
ORColourView *left1 = [[ORColourView alloc] init];
left1.text = @"Tap Me";
left1.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 55};
ORColourView *right1 = [[ORColourView alloc] init];
right1.text = @"Tap Me";
right1.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 20};
UITapGestureRecognizer *leftGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addView:)];
[left1 addGestureRecognizer:leftGesture];
UITapGestureRecognizer *rightGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addView:)];
[right1 addGestureRecognizer:rightGesture];
ORColourView *left2 = [[ORColourView alloc] init];
left2.text = @"a view";
left2.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 40};
ORColourView *left3 = [[ORColourView alloc] init];
left3.text = @"a view";
left3.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 45};
ORColourView *right2 = [[ORColourView alloc] init];
right2.text = @"a view";
right2.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 35};
ORColourView *right3 = [[ORColourView alloc] init];
right3.text = @"a view";
right3.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 50};
[view4.leftStack addSubview:left1 withPrecedingMargin:0.0 sideMargin:10.0];
[view4.leftStack addSubview:left2 withPrecedingMargin:10.0 sideMargin:5.0];
[view4.leftStack addSubview:left3 withPrecedingMargin:10.0 sideMargin:15.0];
[view4.rightStack addSubview:right1 withPrecedingMargin:0.0 sideMargin:15.0];
[view4.rightStack addSubview:right2 withPrecedingMargin:10.0 sideMargin:10.0];
[view4.rightStack addSubview:right3 withPrecedingMargin:10.0 sideMargin:5.0];
[self.view.stackView addSubview:view1 withPrecedingMargin:20.0 sideMargin:40.0];
[self.view.stackView addSubview:view2 withPrecedingMargin:10.0 sideMargin:30.0];
[self.view.stackView addSubview:view3 withPrecedingMargin:10.0 sideMargin:35.0];
[self.view.stackView addSubview:view4 withPrecedingMargin:15.0 sideMargin:30.0];
[self.view.stackView addSubview:view5 withPrecedingMargin:20.0 sideMargin:15.0];
[self.view.stackView addSubview:view6 withPrecedingMargin:10.0 sideMargin:20.0];
[self.view.stackView addSubview:view7 withPrecedingMargin:15.0 sideMargin:30.0];
}
- (void)addView:(UITapGestureRecognizer *)gesture
{
ORColourView *view = [[ORColourView alloc] init];
view.text = @"Tap to remove";
view.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 40 };
[(ORStackView *)gesture.view.superview addSubview:view withPrecedingMargin:5.0 sideMargin:10.0];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeTappedView:)];
[view addGestureRecognizer:tapGesture];
}
- (void)removeTappedView:(UITapGestureRecognizer *)gesture
{
[(ORStackView *)gesture.view.superview removeSubview:gesture.view];
}
@end