@@ -66,7 +66,7 @@ - (void)setUp
66
66
_currentLayout = _defaultContentLayout;
67
67
_contentLayouts = @[[TOPasscodeViewContentLayout mediumScreenContentLayout ],
68
68
[TOPasscodeViewContentLayout smallScreenContentLayout ]];
69
- _titleText = @" Enter Passcode" ;
69
+ _titleText = NSLocalizedString( @" Enter Passcode" , @" " ) ;
70
70
71
71
// Start configuring views
72
72
[self setUpViewForType: self .passcodeType];
@@ -144,36 +144,33 @@ - (void)horizontallyLayoutSubviews
144
144
CGSize midViewSize = (CGSize){self.frame .size .width * 0 .5f , self.frame .size .height * 0 .5f };
145
145
CGRect frame = CGRectZero;
146
146
147
- // Work out total height of header content
148
- CGFloat headerHeight = 0 .0f ;
147
+ // Work out the y offset, assuming the input field is in the middle
148
+ frame.origin .y = midViewSize.height - (self.inputField .frame .size .height * 0 .5f );
149
+ frame.origin .y -= (self.titleLabel .frame .size .height + self.currentLayout .titleLabelHorizontalBottomSpacing );
150
+
151
+ // Include offset for title view if present
149
152
if (self.titleView ) {
150
- headerHeight += self.titleView .frame .size .height ;
151
- headerHeight += self.currentLayout .titleViewBottomSpacing ;
153
+ frame.origin .y -= (self.titleView .frame .size .height + self.currentLayout .titleViewHorizontalBottomSpacing );
152
154
}
153
155
154
- headerHeight += self.titleLabel .frame .size .height ;
155
- headerHeight += self.currentLayout .titleLabelBottomSpacing ;
156
-
157
- headerHeight += self.inputField .frame .size .height ;
158
-
159
156
// Set initial Y offset
160
- frame.origin .y = midViewSize. height - (headerHeight * 0 . 5f );
157
+ frame.origin .y = MAX (frame. origin . y , 0 . 0f );
161
158
162
159
// Set frame of title view
163
160
if (self.titleView ) {
164
161
frame.size = self.titleView .frame .size ;
165
162
frame.origin .x = (self.currentLayout .titleHorizontalLayoutWidth - frame.size .width ) * 0 .5f ;
166
163
self.titleView .frame = CGRectIntegral (frame);
167
164
168
- frame.origin .y += (frame.size .height + self.currentLayout .titleViewBottomSpacing );
165
+ frame.origin .y += (frame.size .height + self.currentLayout .titleViewHorizontalBottomSpacing );
169
166
}
170
167
171
168
// Set frame of title label
172
169
frame.size = self.titleLabel .frame .size ;
173
170
frame.origin .x = (self.currentLayout .titleHorizontalLayoutWidth - frame.size .width ) * 0 .5f ;
174
171
self.titleLabel .frame = CGRectIntegral (frame);
175
172
176
- frame.origin .y += (frame.size .height + self.currentLayout .titleLabelBottomSpacing );
173
+ frame.origin .y += (frame.size .height + self.currentLayout .titleLabelHorizontalBottomSpacing );
177
174
178
175
// Set frame of the input field
179
176
frame.size = self.inputField .frame .size ;
0 commit comments