Skip to content

Commit 0614fe7

Browse files
committed
Adjusted iPhone 7 sizing
1 parent 311b3a6 commit 0614fe7

File tree

5 files changed

+80
-16
lines changed

5 files changed

+80
-16
lines changed

TOPasscodeViewController/Models/TOPasscodeViewContentLayout.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
/* The width of the PIN view in which this layout object is sizing the content to fit. */
1515
@property (nonatomic, assign) CGFloat viewWidth;
1616

17+
/* Extra padding at the bottom in order to shift the content slightly up */
18+
@property (nonatomic, assign) CGFloat bottomPadding;
19+
1720
/* The title view at the very top */
1821
@property (nonatomic, assign) CGFloat titleViewBottomSpacing; // Space from the bottom of the title view to the title label
1922

TOPasscodeViewController/Models/TOPasscodeViewContentLayout.m

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ + (TOPasscodeViewContentLayout *)defaultScreenContentLayout
1717
/* Width of the PIN View */
1818
contentLayout.viewWidth = 414.0f;
1919

20+
/* Bottom Padding */
21+
contentLayout.bottomPadding = 25.0f;
22+
2023
/* Title View Constraints */
2124
contentLayout.titleViewBottomSpacing = 34.0f;
2225

@@ -67,11 +70,14 @@ + (TOPasscodeViewContentLayout *)mediumScreenContentLayout
6770
/* Width of the PIN View */
6871
contentLayout.viewWidth = 375.0f;
6972

73+
/* Bottom Padding */
74+
contentLayout.bottomPadding = 17.0f;
75+
7076
/* Title View Constraints */
7177
contentLayout.titleViewBottomSpacing = 27.0f;
7278

7379
/* The Title Label Explaining the PIN View */
74-
contentLayout.titleLabelBottomSpacing = 27.0f;
80+
contentLayout.titleLabelBottomSpacing = 24.0f;
7581
contentLayout.titleLabelFont = [UIFont systemFontOfSize: 20.0f];
7682

7783
/* Horizontal title constraints */
@@ -115,6 +121,9 @@ + (TOPasscodeViewContentLayout *)smallScreenContentLayout
115121
/* Width of the PIN View */
116122
contentLayout.viewWidth = 320.0f;
117123

124+
/* Bottom Padding */
125+
contentLayout.bottomPadding = 12.0f;
126+
118127
/* Title View Constraints */
119128
contentLayout.titleViewBottomSpacing = 23.0f;
120129

@@ -124,7 +133,7 @@ + (TOPasscodeViewContentLayout *)smallScreenContentLayout
124133

125134
/* Horizontal title constraints */
126135
contentLayout.titleHorizontalLayoutWidth = 185.0f;
127-
contentLayout.titleHorizontalLayoutSpacing = 16.0f;
136+
contentLayout.titleHorizontalLayoutSpacing = 5.0f;
128137
contentLayout.titleViewHorizontalBottomSpacing = 18.0f;
129138
contentLayout.titleLabelHorizontalBottomSpacing = 18.0f;
130139

@@ -147,13 +156,13 @@ + (TOPasscodeViewContentLayout *)smallScreenContentLayout
147156
contentLayout.submitButtonSpacing = 3.0f;
148157

149158
/* Circle Button Shape and Layout */
150-
contentLayout.circleButtonDiameter = 64.0f;
151-
contentLayout.circleButtonSpacing = (CGSize){22.0f, 10.5f};
159+
contentLayout.circleButtonDiameter = 76.0f;
160+
contentLayout.circleButtonSpacing = (CGSize){20.0f, 12.5f};
152161
contentLayout.circleButtonStrokeWidth = 1.5f;
153162

154163
/* Circle Button Label */
155-
contentLayout.circleButtonTitleLabelFont = [UIFont systemFontOfSize:32.0f weight:UIFontWeightThin];
156-
contentLayout.circleButtonLetteringLabelFont = [UIFont systemFontOfSize:7.0f weight:UIFontWeightThin];
164+
contentLayout.circleButtonTitleLabelFont = [UIFont systemFontOfSize:35.0f weight:UIFontWeightThin];
165+
contentLayout.circleButtonLetteringLabelFont = [UIFont systemFontOfSize:9.0f weight:UIFontWeightThin];
157166
contentLayout.circleButtonLabelSpacing = 4.5f;
158167
contentLayout.circleButtonLetteringSpacing = 2.0f;
159168

TOPasscodeViewController/TOPasscodeViewController.m

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,6 @@ - (void)viewDidLayoutSubviews
201201
{
202202
CGSize bounds = self.view.bounds.size;
203203

204-
// Update the accessory button sizes
205-
[self updateAccessoryButtonFontsForSize:bounds];
206-
207-
// Re-layout the accessory buttons
208-
[self layoutAccessoryButtonsForSize:bounds];
209-
210204
// Resize the pin view to scale to the new size
211205
[self.passcodeView sizeToFitSize:bounds];
212206

@@ -215,6 +209,14 @@ - (void)viewDidLayoutSubviews
215209
frame.origin.x = (bounds.width - frame.size.width) * 0.5f;
216210
frame.origin.y = ((bounds.height - self.keyboardHeight) - frame.size.height) * 0.5f;
217211
self.passcodeView.frame = CGRectIntegral(frame);
212+
213+
// --------------------------------------------------
214+
215+
// Update the accessory button sizes
216+
[self updateAccessoryButtonFontsForSize:bounds];
217+
218+
// Re-layout the accessory buttons
219+
[self layoutAccessoryButtonsForSize:bounds];
218220
}
219221

220222
- (void)viewWillAppear:(BOOL)animated
@@ -306,10 +308,8 @@ - (void)updateAccessoryButtonFontsForSize:(CGSize)size
306308
self.rightAccessoryButton.titleLabel.font = accessoryFont;
307309
}
308310

309-
- (void)layoutAccessoryButtonsForSize:(CGSize)size
311+
- (void)verticalLayoutAccessoryButtonsForSize:(CGSize)size
310312
{
311-
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone) { return; }
312-
313313
CGFloat width = MIN(size.width, size.height);
314314

315315
CGFloat verticalInset = 54.0f;
@@ -338,6 +338,55 @@ - (void)layoutAccessoryButtonsForSize:(CGSize)size
338338
}
339339
}
340340

341+
- (void)horizontalLayoutAccessoryButtonsForSize:(CGSize)size
342+
{
343+
CGRect passcodeViewFrame = self.passcodeView.frame;
344+
CGFloat buttonInset = self.passcodeView.keypadButtonInset;
345+
CGFloat width = MIN(size.width, size.height);
346+
CGFloat verticalInset = 35.0f;
347+
if (width < TOPasscodeViewContentSizeMedium) {
348+
verticalInset = 30.0f;
349+
}
350+
else if (width < TOPasscodeViewContentSizeDefault) {
351+
verticalInset = 35.0f;
352+
}
353+
354+
355+
UIButton *leftButton = self.leftAccessoryButton ? self.leftAccessoryButton : self.biometricButton;
356+
if (leftButton) {
357+
[leftButton sizeToFit];
358+
CGRect frame = leftButton.frame;
359+
frame.origin.y = (self.view.bounds.size.height - verticalInset) - (frame.size.height * 0.5f);
360+
frame.origin.x = (CGRectGetMaxX(passcodeViewFrame) - buttonInset) - (frame.size.width * 0.5f);
361+
leftButton.frame = CGRectIntegral(frame);
362+
}
363+
364+
UIButton *rightButton = self.rightAccessoryButton ? self.rightAccessoryButton : self.cancelButton;
365+
if (rightButton) {
366+
[rightButton sizeToFit];
367+
CGRect frame = rightButton.frame;
368+
frame.origin.y = verticalInset - (frame.size.height * 0.5f);
369+
frame.origin.x = (CGRectGetMaxX(passcodeViewFrame) - buttonInset) - (frame.size.width * 0.5f);
370+
rightButton.frame = CGRectIntegral(frame);
371+
}
372+
373+
[self.view bringSubviewToFront:rightButton];
374+
[self.view bringSubviewToFront:leftButton];
375+
}
376+
377+
- (void)layoutAccessoryButtonsForSize:(CGSize)size
378+
{
379+
// The buttons are always embedded in the keypad view on iPad
380+
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone) { return; }
381+
382+
if (self.passcodeView.horizontalLayout) {
383+
[self horizontalLayoutAccessoryButtonsForSize:size];
384+
}
385+
else {
386+
[self verticalLayoutAccessoryButtonsForSize:size];
387+
}
388+
}
389+
341390
#pragma mark - Interactions -
342391
- (void)accessoryButtonTapped:(id)sender
343392
{

TOPasscodeViewController/Views/Main/TOPasscodeView.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ - (void)verticalSizeToFit
270270
frame.size.height += maxHeight;
271271
}
272272

273+
// Add extra padding at the bottom
274+
frame.size.height += self.currentLayout.bottomPadding;
275+
273276
// Set the frame back
274277
self.frame = CGRectIntegral(frame);
275278
}

TOPasscodeViewController/Views/Shared/TOPasscodeFixedInputView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ - (void)setCircleViewsForLength:(NSInteger)length
109109

110110
- (void)setCircleImagesForDiameter:(CGFloat)diameter
111111
{
112-
self.circleImage = [TOPasscodeCircleImage hollowCircleImageOfSize:diameter strokeWidth:1.0f padding:1.0f];
112+
self.circleImage = [TOPasscodeCircleImage hollowCircleImageOfSize:diameter strokeWidth:1.2f padding:1.0f];
113113
self.highlightedCircleImage = [TOPasscodeCircleImage circleImageOfSize:diameter inset:0.5f padding:1.0f antialias:NO];
114114

115115
for (TOPasscodeCircleView *circleView in self.circleViews) {

0 commit comments

Comments
 (0)