@@ -17,12 +17,15 @@ @interface MTZWhatsNewViewController ()
17
17
// / A private read/write property of `contentView`.
18
18
@property (readwrite ) UIView *contentView;
19
19
20
- // / A private read/write property of `contentInsets `.
21
- @property (readwrite ) UIEdgeInsets contentInsets ;
20
+ // / A private read/write property of `contentInset `.
21
+ @property (readwrite ) UIEdgeInsets contentInset ;
22
22
23
23
// / The button to dismiss the view controller.
24
24
@property (strong , nonatomic ) UIButton *dismissButton;
25
25
26
+ // / The background behind the dismiss button.
27
+ @property (strong , nonatomic ) UIToolbar *buttonBackground;
28
+
26
29
@end
27
30
28
31
@@ -71,10 +74,6 @@ - (void)commonInit
71
74
self.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
72
75
self.modalPresentationStyle = UIModalPresentationFormSheet;
73
76
74
- CGFloat buttonHeight = [self shouldUseLargeButton ] ? 82 .0f : 50 .0f ;
75
- UIFont *buttonFont = [self shouldUseLargeButton ] ? [UIFont fontWithName: @" HelveticaNeue-Light" size: 29 .0f ] : [UIFont fontWithName: @" HelveticaNeue" size: 18 .0f ];
76
- self.contentInsets = UIEdgeInsetsMake (0 , 0 , buttonHeight, 0 );
77
-
78
77
// Background View.
79
78
SAMGradientView *gradientView = [[SAMGradientView alloc ] init ];
80
79
self.backgroundView = gradientView;
@@ -91,20 +90,19 @@ - (void)commonInit
91
90
[self .view addConstraints: [NSLayoutConstraint constraintsToFillToSuperview: self .contentView]];
92
91
93
92
// Dismiss Button.
94
- UIToolbar *buttonBackground = [[UIToolbar alloc ] init ];
95
- [self .view addSubview: buttonBackground];
96
- buttonBackground.translatesAutoresizingMaskIntoConstraints = NO ;
97
- [self .view addConstraints: [NSLayoutConstraint constraintsToStickView: buttonBackground toEdges: UIRectEdgeLeft|UIRectEdgeBottom|UIRectEdgeRight]];
98
- [buttonBackground addConstraint: [NSLayoutConstraint constraintToSetStaticHeight: buttonHeight toView: buttonBackground]];
93
+ self.buttonBackground = [[UIToolbar alloc ] init ];
94
+ [self .view addSubview: self .buttonBackground];
95
+ self.buttonBackground .translatesAutoresizingMaskIntoConstraints = NO ;
96
+ [self .view addConstraints: [NSLayoutConstraint constraintsToStickView: self .buttonBackground toEdges: UIRectEdgeLeft|UIRectEdgeBottom|UIRectEdgeRight]];
99
97
100
98
self.dismissButton = [[UIButton alloc ] init ];
101
99
self.dismissButton = [UIButton buttonWithType: UIButtonTypeRoundedRect];
102
- [buttonBackground addSubview: self .dismissButton];
100
+ [self . buttonBackground addSubview: self .dismissButton];
103
101
self.dismissButton .translatesAutoresizingMaskIntoConstraints = NO ;
104
- [self .dismissButton.superview addConstraints: [NSLayoutConstraint constraintsToFillToSuperview: self .dismissButton]];
105
- self.dismissButton .titleLabel .font = buttonFont;
106
102
[self .dismissButton addTarget: self action: @selector (didTapContinueButton: ) forControlEvents: UIControlEventTouchUpInside];
107
103
104
+ [self reloadButtonHeight ];
105
+
108
106
// Defaults.
109
107
self.backgroundGradientTopColor = [UIColor whiteColor ];
110
108
self.backgroundGradientBottomColor = [UIColor whiteColor ];
@@ -113,11 +111,30 @@ - (void)commonInit
113
111
self.dismissButtonTitle = NSLocalizedString(@" Get Started" , nil );
114
112
}
115
113
114
+ - (void )reloadButtonHeight
115
+ {
116
+ UIFont *buttonFont = [self shouldUseLargeButton ] ? [UIFont fontWithName: @" HelveticaNeue-Light" size: 29 .0f ] : [UIFont fontWithName: @" HelveticaNeue" size: 18 .0f ];
117
+ self.dismissButton .titleLabel .font = buttonFont;
118
+
119
+ CGFloat buttonHeight = [self shouldUseLargeButton ] ? 82 .0f : 50 .0f ;
120
+ [self .buttonBackground removeConstraints: self .buttonBackground.constraints];
121
+ [self .buttonBackground addConstraint: [NSLayoutConstraint constraintToSetStaticHeight: buttonHeight toView: self .buttonBackground]];
122
+ [self .buttonBackground addConstraints: [NSLayoutConstraint constraintsToFillToSuperview: self .dismissButton]];
123
+
124
+ self.contentInset = UIEdgeInsetsMake (self.topLayoutGuide .length , 0 , self.bottomLayoutGuide .length +buttonHeight, 0 );
125
+ }
126
+
116
127
- (BOOL )prefersStatusBarHidden
117
128
{
118
129
return YES ;
119
130
}
120
131
132
+ - (void )viewWillLayoutSubviews
133
+ {
134
+ [super viewWillLayoutSubviews ];
135
+ [self reloadButtonHeight ];
136
+ }
137
+
121
138
122
139
#pragma mark - Actions
123
140
@@ -172,6 +189,12 @@ - (void)setDismissButtonTitle:(NSString *)dismissButtonText
172
189
[self .dismissButton setTitle: _dismissButtonTitle forState: UIControlStateNormal];
173
190
}
174
191
192
+ - (void )setContentInset : (UIEdgeInsets)contentInset
193
+ {
194
+ _contentInset = contentInset;
195
+ [self contentInsetDidChange ];
196
+ }
197
+
175
198
176
199
#pragma mark - Style
177
200
@@ -201,6 +224,11 @@ - (MTZWhatsNewViewControllerStyle)appropriateStyleForBackgroundOfColor:(UIColor
201
224
}
202
225
}
203
226
227
+ - (void )contentInsetDidChange
228
+ {
229
+ // An empty implementation.
230
+ }
231
+
204
232
- (void )styleDidChange
205
233
{
206
234
// An empty implementation.
0 commit comments