@@ -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{
0 commit comments