Visitar URL original
Use CGFloat instead of NSString as margin · orta/ORStackView@81b5126 · GitHub
Skip to content

Commit 81b5126

Browse files
committed
Use CGFloat instead of NSString as margin
1 parent 3b7c2c6 commit 81b5126

11 files changed

Lines changed: 71 additions & 88 deletions

‎Classes/ios/ORStackView.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,33 @@
1313

1414
/// Adds a view to the heirarchy, if it's the first it is
1515
/// attached to the top, otherwise to the view above.
16-
- (void)addSubview:(UIView *)view withTopMargin:(NSString *)margin;
16+
- (void)addSubview:(UIView *)view withTopMargin:(CGFloat)margin;
1717

1818
/// Adds a view to the heirarchy like addSubview:withTopMargin:
1919
/// will also center and apply side margins as insets from edge
20-
- (void)addSubview:(UIView *)view withTopMargin:(NSString *)topMargin sideMargin:(NSString *)sideMargin;
20+
- (void)addSubview:(UIView *)view withTopMargin:(CGFloat)topMargin sideMargin:(CGFloat)sideMargin;
2121

2222
/// Adds a view controller's view to the stack heirarchy
23-
- (void)addViewController:(UIViewController *)viewController toParent:(UIViewController *)parentViewController withTopMargin:(NSString *)margin;
23+
- (void)addViewController:(UIViewController *)viewController toParent:(UIViewController *)parentViewController withTopMargin:(CGFloat)margin;
2424

2525
/// Adds a view controller's view to the stack heirarchy, and applys edge insets
26-
- (void)addViewController:(UIViewController *)viewController toParent:(UIViewController *)parentViewController withTopMargin:(NSString *)margin sideMargin:(NSString *)sideMargin;
26+
- (void)addViewController:(UIViewController *)viewController toParent:(UIViewController *)parentViewController withTopMargin:(CGFloat)margin sideMargin:(CGFloat)sideMargin;
2727

2828

2929
// Note: These indexes are not z-order, but stack order.
3030
// z-index ordering can be done with the UIView methods bringSubviewToFront:
3131

3232
/// Insert a subview at an arbitrary index in the stack's order
33-
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(NSString *)margin;
33+
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(CGFloat)margin;
3434

3535
/// Inserts a subview and centeres it
36-
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(NSString *)topMargin sideMargin:(NSString *)sideMargin;
36+
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(CGFloat)topMargin sideMargin:(CGFloat)sideMargin;
3737

3838
/// Insert a subview below another view, or at the end if it cannot be found
39-
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview withTopMargin:(NSString *)margin;
39+
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview withTopMargin:(CGFloat)margin;
4040

4141
/// Insert a subview above another view, will assert if view is not found
42-
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview withTopMargin:(NSString *)margin;
42+
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview withTopMargin:(CGFloat)margin;
4343

4444
/// Remove a subview from the Stack View
4545
- (void)removeSubview:(UIView *)subview;

‎Classes/ios/ORStackView.m‎

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -90,51 +90,51 @@ - (void)updateConstraints
9090

9191
#pragma mark - Adding Subviews
9292

93-
- (void)addSubview:(UIView *)view withTopMargin:(NSString *)margin
93+
- (void)addSubview:(UIView *)view withTopMargin:(CGFloat)margin
9494
{
95-
[self _addSubview:view withTopMargin:margin centered:NO sideMargin:nil];
95+
[self _addSubview:view withTopMargin:margin centered:NO sideMargin:0];
9696
}
9797

98-
- (void)addSubview:(UIView *)view withTopMargin:(NSString *)topMargin sideMargin:(NSString *)sideMargin
98+
- (void)addSubview:(UIView *)view withTopMargin:(CGFloat)topMargin sideMargin:(CGFloat)sideMargin
9999
{
100100
[self _addSubview:view withTopMargin:topMargin centered:YES sideMargin:sideMargin];
101101
}
102102

103-
- (void)_addSubview:(UIView *)view withTopMargin:(NSString *)topMargin centered:(BOOL)centered sideMargin:(NSString *)sideMargin
103+
- (void)_addSubview:(UIView *)view withTopMargin:(CGFloat)topMargin centered:(BOOL)centered sideMargin:(CGFloat)sideMargin
104104
{
105105
NSInteger index = self.viewStack.count;
106106
[self _insertSubview:view atIndex:index withTopMargin:topMargin centered:centered sideMargin:sideMargin];
107107
}
108108

109109
#pragma mark - Inserting Subviews
110110

111-
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(NSString *)margin;
111+
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(CGFloat)margin;
112112
{
113-
[self _insertSubview:view atIndex:index withTopMargin:margin centered:NO sideMargin:nil];
113+
[self _insertSubview:view atIndex:index withTopMargin:margin centered:NO sideMargin:0];
114114
}
115115

116-
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(NSString *)topMargin sideMargin:(NSString *)sideMargin
116+
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(CGFloat)topMargin sideMargin:(CGFloat)sideMargin
117117
{
118118
[self _insertSubview:view atIndex:index withTopMargin:topMargin centered:YES sideMargin:sideMargin];
119119
}
120120

121121

122-
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview withTopMargin:(NSString *)margin
122+
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview withTopMargin:(CGFloat)margin
123123
{
124124
BOOL hasSibling = [self.subviews containsObject:siblingSubview];
125125
NSInteger index = hasSibling ? [self indexOfView:siblingSubview] : self.viewStack.count;
126-
[self _insertSubview:view atIndex:index withTopMargin:margin centered:NO sideMargin:nil];
126+
[self _insertSubview:view atIndex:index withTopMargin:margin centered:NO sideMargin:0];
127127
}
128128

129-
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview withTopMargin:(NSString *)margin
129+
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview withTopMargin:(CGFloat)margin
130130
{
131131
NSAssert([self.subviews containsObject:siblingSubview], @"SiblingSubview not found in ORStackView");
132132

133133
NSInteger index = [self indexOfView:siblingSubview] - 1;
134-
[self _insertSubview:view atIndex:index withTopMargin:margin centered:NO sideMargin:nil];
134+
[self _insertSubview:view atIndex:index withTopMargin:margin centered:NO sideMargin:0];
135135
}
136136

137-
- (void)_insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(NSString *)topMargin centered:(BOOL)centered sideMargin:(NSString *)sideMargin
137+
- (void)_insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(CGFloat)topMargin centered:(BOOL)centered sideMargin:(CGFloat)sideMargin
138138
{
139139
NSParameterAssert(view);
140140
if ([self.subviews containsObject:view]) return;
@@ -143,28 +143,11 @@ - (void)_insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(NS
143143

144144
StackView *stackView = [[StackView alloc] init];
145145
stackView.view = view;
146-
stackView.constraintPredicate = topMargin;
146+
stackView.constraintPredicate = @(topMargin).stringValue;
147147
[self.viewStack insertObject:stackView atIndex:index];
148148

149149
if (centered) {
150-
NSString *newSidemargin;
151-
if ([sideMargin rangeOfString:@"-"].location == NSNotFound) {
152-
NSMutableString *mutableSideMargin = [sideMargin mutableCopy];
153-
NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:@"[0-9]" options:0 error:NULL];
154-
NSInteger matchLocation = [regex rangeOfFirstMatchInString:mutableSideMargin options:0 range:NSMakeRange(0, [mutableSideMargin length])].location;
155-
[mutableSideMargin insertString:@"-" atIndex:matchLocation];
156-
newSidemargin = [mutableSideMargin copy];
157-
} else {
158-
newSidemargin = [sideMargin stringByReplacingOccurrencesOfString:@"-" withString:@""];
159-
}
160-
161-
if ([newSidemargin rangeOfString:@">"].location != NSNotFound) {
162-
newSidemargin = [newSidemargin stringByReplacingOccurrencesOfString:@">" withString:@"<"];
163-
} else if ([newSidemargin rangeOfString:@"<"].location != NSNotFound) {
164-
newSidemargin = [newSidemargin stringByReplacingOccurrencesOfString:@"<" withString:@">"];
165-
}
166-
167-
[view constrainWidthToView:self predicate:newSidemargin];
150+
[view constrainWidthToView:self predicate:@(-sideMargin).stringValue];
168151
[view alignCenterXWithView:self predicate:nil];
169152
}
170153

@@ -211,15 +194,15 @@ - (void)performBatchUpdates:(void (^)(void))updates;
211194
[self setNeedsUpdateConstraints];
212195
}
213196

214-
- (void)addViewController:(UIViewController *)viewController toParent:(UIViewController *)parentViewController withTopMargin:(NSString *)margin
197+
- (void)addViewController:(UIViewController *)viewController toParent:(UIViewController *)parentViewController withTopMargin:(CGFloat)margin
215198
{
216199
[viewController willMoveToParentViewController:parentViewController];
217200
[parentViewController addChildViewController:viewController];
218201
[self addSubview:viewController.view withTopMargin:margin];
219202
[viewController didMoveToParentViewController:parentViewController];
220203
}
221204

222-
- (void)addViewController:(UIViewController *)viewController toParent:(UIViewController *)parentViewController withTopMargin:(NSString *)margin sideMargin:(NSString *)sideMargin;
205+
- (void)addViewController:(UIViewController *)viewController toParent:(UIViewController *)parentViewController withTopMargin:(CGFloat)margin sideMargin:(CGFloat)sideMargin;
223206
{
224207
[viewController willMoveToParentViewController:parentViewController];
225208
[parentViewController addChildViewController:viewController];

‎Classes/ios/ORTagBasedAutoStackView.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717

1818
// Please don't use the insert methods on this class
19-
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(NSString *)margin __attribute__((unavailable("Inserting subviews is not supported on ORTagBasedAutoStackView.")));
19+
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(CGFloat)margin __attribute__((unavailable("Inserting subviews is not supported on ORTagBasedAutoStackView.")));
2020

2121
// Please don't use the insert methods on this class
22-
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(NSString *)topMargin sideMargin:(NSString *)sideMargin __attribute__((unavailable("Inserting subviews is not supported on ORTagBasedAutoStackView.")));
22+
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(CGFloat)topMargin sideMargin:(CGFloat)sideMargin __attribute__((unavailable("Inserting subviews is not supported on ORTagBasedAutoStackView.")));
2323

2424
// Please don't use the insert methods on this class
25-
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview withTopMargin:(NSString *)margin __attribute__((unavailable("Inserting subviews is not supported on ORTagBasedAutoStackView.")));
25+
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview withTopMargin:(CGFloat)margin __attribute__((unavailable("Inserting subviews is not supported on ORTagBasedAutoStackView.")));
2626

2727
// Please don't use the insert methods on this class
28-
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview withTopMargin:(NSString *)margin __attribute__((unavailable("Inserting subviews is not supported on ORTagBasedAutoStackView.")));
28+
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview withTopMargin:(CGFloat)margin __attribute__((unavailable("Inserting subviews is not supported on ORTagBasedAutoStackView.")));
2929

3030
@end

‎Classes/ios/ORTagBasedAutoStackView.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
@implementation ORTagBasedAutoStackView
1313

14-
- (void)_addSubview:(UIView *)view withTopMargin:(NSString *)topMargin centered:(BOOL)centered sideMargin:(NSString *)sideMargin
14+
- (void)_addSubview:(UIView *)view withTopMargin:(CGFloat)topMargin centered:(BOOL)centered sideMargin:(CGFloat)sideMargin
1515
{
1616
NSInteger index = self.viewStack.count;
1717
for (StackView *stackView in self.viewStack) {

‎Classes/ios/private/ORStackView+Private.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
@property (nonatomic, strong) NSMutableArray *viewStack;
2323

2424
// Methods that allow subclasses to make changes around how views are inserted.
25-
- (void)_addSubview:(UIView *)view withTopMargin:(NSString *)topMargin centered:(BOOL)centered sideMargin:(NSString *)sideMargin;
25+
- (void)_addSubview:(UIView *)view withTopMargin:(CGFloat)topMargin centered:(BOOL)centered sideMargin:(CGFloat)sideMargin;
2626

2727
// Methods that allow subclasses to make changes around how views are inserted.
28-
- (void)_insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(NSString *)topMargin centered:(BOOL)centered sideMargin:(NSString *)sideMargin;
28+
- (void)_insertSubview:(UIView *)view atIndex:(NSInteger)index withTopMargin:(CGFloat)topMargin centered:(BOOL)centered sideMargin:(CGFloat)sideMargin;
2929
@end

‎ORStackView.podspec‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Pod::Spec.new do |s|
22
s.name = "ORStackView"
3-
s.version = "2.0.0"
3+
s.version = "3.0.0"
44
s.summary = "An Auto Layout based Stack View."
55
s.description = <<-DESC
6-
Vertically stack views using Auto Layout, also includes an
6+
Vertically stack views using Auto Layout, also includes an
77
order specific subclass that uses view tags for ordering.
88
DESC
99
s.homepage = "https://github.com/orta/ORStackView"
10-
10+
1111
s.license = 'MIT'
1212
s.author = { "Orta Therox" => "orta.therox@gmail.com" }
1313
s.social_media_url = "http://twitter.com/orta"
@@ -18,6 +18,6 @@ Pod::Spec.new do |s|
1818

1919
s.source_files = 'Classes/ios/*', 'Classes/ios/private/*'
2020
s.private_header_files = 'Classes/ios/private/*.h'
21-
21+
2222
s.dependency 'FLKAutoLayout', '~> 0.1'
2323
end

‎ORStackViewExample/ORFifthViewController.m‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,20 @@ - (void)viewDidLoad
8686
right3.text = @"a view";
8787
right3.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 50};
8888

89-
[view4.leftStack addSubview:left1 withTopMargin:@"0" sideMargin:@"10"];
90-
[view4.leftStack addSubview:left2 withTopMargin:@"10" sideMargin:@"5"];
91-
[view4.leftStack addSubview:left3 withTopMargin:@"10" sideMargin:@"15"];
92-
[view4.rightStack addSubview:right1 withTopMargin:@"0" sideMargin:@"15"];
93-
[view4.rightStack addSubview:right2 withTopMargin:@"10" sideMargin:@"10"];
94-
[view4.rightStack addSubview:right3 withTopMargin:@"10" sideMargin:@"5"];
95-
96-
[self.view.stackView addSubview:view1 withTopMargin:@"20" sideMargin:@"40"];
97-
[self.view.stackView addSubview:view2 withTopMargin:@"10" sideMargin:@"30"];
98-
[self.view.stackView addSubview:view3 withTopMargin:@"10" sideMargin:@"35"];
99-
[self.view.stackView addSubview:view4 withTopMargin:@"15" sideMargin:@"30"];
100-
[self.view.stackView addSubview:view5 withTopMargin:@"20" sideMargin:@"15"];
101-
[self.view.stackView addSubview:view6 withTopMargin:@"10" sideMargin:@"20"];
102-
[self.view.stackView addSubview:view7 withTopMargin:@"15" sideMargin:@"30"];
89+
[view4.leftStack addSubview:left1 withTopMargin:0.0 sideMargin:10.0];
90+
[view4.leftStack addSubview:left2 withTopMargin:10.0 sideMargin:5.0];
91+
[view4.leftStack addSubview:left3 withTopMargin:10.0 sideMargin:15.0];
92+
[view4.rightStack addSubview:right1 withTopMargin:0.0 sideMargin:15.0];
93+
[view4.rightStack addSubview:right2 withTopMargin:10.0 sideMargin:10.0];
94+
[view4.rightStack addSubview:right3 withTopMargin:10.0 sideMargin:5.0];
95+
96+
[self.view.stackView addSubview:view1 withTopMargin:20.0 sideMargin:40.0];
97+
[self.view.stackView addSubview:view2 withTopMargin:10.0 sideMargin:30.0];
98+
[self.view.stackView addSubview:view3 withTopMargin:10.0 sideMargin:35.0];
99+
[self.view.stackView addSubview:view4 withTopMargin:15.0 sideMargin:30.0];
100+
[self.view.stackView addSubview:view5 withTopMargin:20.0 sideMargin:15.0];
101+
[self.view.stackView addSubview:view6 withTopMargin:10.0 sideMargin:20.0];
102+
[self.view.stackView addSubview:view7 withTopMargin:15.0 sideMargin:30.0];
103103

104104
}
105105

@@ -108,7 +108,7 @@ - (void)addView:(UITapGestureRecognizer *)gesture
108108
ORColourView *view = [[ORColourView alloc] init];
109109
view.text = @"Tap to remove";
110110
view.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 40 };
111-
[(ORStackView *)gesture.view.superview addSubview:view withTopMargin:@"5" sideMargin:@"10"];
111+
[(ORStackView *)gesture.view.superview addSubview:view withTopMargin:5.0 sideMargin:10.0];
112112

113113
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeTappedView:)];
114114
[view addGestureRecognizer:tapGesture];

‎ORStackViewExample/ORFirstViewController.m‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ - (void)viewDidLoad
5252
view3.text = @"By default, new subviews are added to the bottom of ORStackView.";
5353
view3.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 100 };
5454

55-
[self.stackView addSubview:view1 withTopMargin:@"20" sideMargin:@"30"];
56-
[self.stackView addSubview:view2 withTopMargin:@"40" sideMargin:@"70"];
57-
[self.stackView addSubview:view3 withTopMargin:@"30" sideMargin:@"20"];
55+
[self.stackView addSubview:view1 withTopMargin:20.0 sideMargin:30.0];
56+
[self.stackView addSubview:view2 withTopMargin:40.0 sideMargin:70.0];
57+
[self.stackView addSubview:view3 withTopMargin:30.0 sideMargin:20.0];
5858
}
5959

6060
- (void)addView
6161
{
6262
ORColourView *view = [[ORColourView alloc] init];
6363
view.text = @"Tap to remove";
6464
view.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 24 };
65-
[self.stackView addSubview:view withTopMargin:@"5" sideMargin:@"40"];
65+
[self.stackView addSubview:view withTopMargin:5.0 sideMargin:40.0];
6666

6767
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeTappedView:)];
6868
[view addGestureRecognizer:tapGesture];

‎ORStackViewExample/ORFourthViewController.m‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,20 @@ - (void)viewDidLoad
6060
right3.text = @"a view";
6161
right3.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 40};
6262

63-
[splitView.leftStack addSubview:left1 withTopMargin:@"0" sideMargin:@"10"];
64-
[splitView.leftStack addSubview:left2 withTopMargin:@"10" sideMargin:@"5"];
65-
[splitView.leftStack addSubview:left3 withTopMargin:@"10" sideMargin:@"15"];
66-
[splitView.rightStack addSubview:right1 withTopMargin:@"0" sideMargin:@"15"];
67-
[splitView.rightStack addSubview:right2 withTopMargin:@"10" sideMargin:@"10"];
68-
[splitView.rightStack addSubview:right3 withTopMargin:@"10" sideMargin:@"5"];
63+
[splitView.leftStack addSubview:left1 withTopMargin:0.0 sideMargin:10.0];
64+
[splitView.leftStack addSubview:left2 withTopMargin:10.0 sideMargin:5.0];
65+
[splitView.leftStack addSubview:left3 withTopMargin:10.0 sideMargin:15.0];
66+
[splitView.rightStack addSubview:right1 withTopMargin:0.0 sideMargin:15.0];
67+
[splitView.rightStack addSubview:right2 withTopMargin:10.0 sideMargin:10.0];
68+
[splitView.rightStack addSubview:right3 withTopMargin:10.0 sideMargin:5.0];
6969
}
7070

7171
- (void)addView:(UITapGestureRecognizer *)gesture
7272
{
7373
ORColourView *view = [[ORColourView alloc] init];
7474
view.text = @"Tap to remove";
7575
view.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 24 };
76-
[(ORStackView *)gesture.view.superview addSubview:view withTopMargin:@"5" sideMargin:@"10"];
76+
[(ORStackView *)gesture.view.superview addSubview:view withTopMargin:5.0 sideMargin:10.0];
7777

7878
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeTappedView:)];
7979
[view addGestureRecognizer:tapGesture];

‎ORStackViewExample/ORSecondViewController.m‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ - (void)viewDidLoad
5555
view4.text = @"4 - Lorem ipsum, etc. etc.";
5656
view4.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 20 };
5757

58-
[self.stackView insertSubview:view2 atIndex:0 withTopMargin:@"20" sideMargin:@"20"];
59-
[self.stackView insertSubview:view4 atIndex:1 withTopMargin:@"15" sideMargin:@"20"];
60-
[self.stackView insertSubview:view1 atIndex:0 withTopMargin:@"10" sideMargin:@"20"];
61-
[self.stackView insertSubview:view3 atIndex:2 withTopMargin:@"10" sideMargin:@"20"];
58+
[self.stackView insertSubview:view2 atIndex:0 withTopMargin:20.0 sideMargin:20.0];
59+
[self.stackView insertSubview:view4 atIndex:1 withTopMargin:15.0 sideMargin:20.0];
60+
[self.stackView insertSubview:view1 atIndex:0 withTopMargin:10.0 sideMargin:20.0];
61+
[self.stackView insertSubview:view3 atIndex:2 withTopMargin:10.0 sideMargin:20.0];
6262
}
6363

6464
- (void)addView
@@ -67,7 +67,7 @@ - (void)addView
6767
view.text = @"new view added at index 2\nTap to remove";
6868
view.fakeContentSize = (CGSize){ UIViewNoIntrinsicMetric , 50 };
6969

70-
[self.stackView insertSubview:view atIndex:2 withTopMargin:@"10" sideMargin:@"10"];
70+
[self.stackView insertSubview:view atIndex:2 withTopMargin:10.0 sideMargin:10.0];
7171
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeTappedView:)];
7272
[view addGestureRecognizer:tapGesture];
7373
}

0 commit comments

Comments
 (0)