@@ -98,7 +98,7 @@ - (void)setUpButtons
9898 self.verticalZeroButton = circleButton;
9999
100100 // Hide the button if it's not vertically laid out
101- if (self.layout != TOPasscodeKeypadLayoutVertical ) {
101+ if (self.horizontalLayout ) {
102102 self.verticalZeroButton .contentAlpha = 0 .0f ;
103103 self.verticalZeroButton .hidden = YES ;
104104 }
@@ -107,7 +107,7 @@ - (void)setUpButtons
107107 self.horizontalZeroButton = circleButton;
108108
109109 // Hide the button if it's not horizontally laid out
110- if (self.layout != TOPasscodeKeypadLayoutHorizontal ) {
110+ if (! self.horizontalLayout ) {
111111 self.horizontalZeroButton .contentAlpha = 0 .0f ;
112112 self.horizontalZeroButton .hidden = YES ;
113113 }
@@ -122,7 +122,7 @@ - (void)sizeToFit
122122 CGFloat padding = 2 .0f ;
123123
124124 CGRect frame = self.frame ;
125- if (self.layout == TOPasscodeKeypadLayoutHorizontal ) {
125+ if (self.horizontalLayout ) {
126126 frame.size .width = ((self.buttonDiameter + padding) * 4 ) + (self.buttonSpacing .width * 3 );
127127 frame.size .height = ((self.buttonDiameter + padding) * 3 ) + (self.buttonSpacing .height * 2 );
128128 }
@@ -228,20 +228,18 @@ - (UIImage *)tappedButtonImage
228228
229229#pragma mark - Public Layout Setters -
230230
231- - (void )setLayout : (TOPasscodeKeypadLayout) layout
231+ - (void )setHorizontalLayout : ( BOOL ) horizontalLayout
232232{
233- [self setLayout: layout animated: NO duration: 0 .0f ];
233+ [self setHorizontalLayout: horizontalLayout animated: NO duration: 0 .0f ];
234234}
235235
236- - (void )setLayout : (TOPasscodeKeypadLayout) layout animated : (BOOL )animated duration : (CGFloat)duration
236+ - (void )setHorizontalLayout : ( BOOL ) horizontalLayout animated : (BOOL )animated duration : (CGFloat)duration
237237{
238- if (layout == _layout ) {
238+ if (horizontalLayout == _horizontalLayout ) {
239239 return ;
240240 }
241241
242- _layout = layout;
243-
244- BOOL toHorizontal = (layout == TOPasscodeKeypadLayoutHorizontal);
242+ _horizontalLayout = horizontalLayout;
245243
246244 // Resize itself now so the frame value is up to date externally
247245 [self sizeToFit ];
@@ -250,17 +248,17 @@ - (void)setLayout:(TOPasscodeKeypadLayout)layout animated:(BOOL)animated duratio
250248 self.verticalZeroButton .hidden = NO ;
251249 self.horizontalZeroButton .hidden = NO ;
252250
253- self.verticalZeroButton .contentAlpha = toHorizontal ? 1 .0f : 0 .0f ;
254- self.horizontalZeroButton .contentAlpha = toHorizontal ? 0 .0f : 1 .0f ;
251+ self.verticalZeroButton .contentAlpha = _horizontalLayout ? 1 .0f : 0 .0f ;
252+ self.horizontalZeroButton .contentAlpha = _horizontalLayout ? 0 .0f : 1 .0f ;
255253
256254 void (^animationBlock)() = ^{
257- self.verticalZeroButton .contentAlpha = toHorizontal ? 0 .0f : 1 .0f ;
258- self.horizontalZeroButton .contentAlpha = toHorizontal ? 1 .0f : 0 .0f ;
255+ self.verticalZeroButton .contentAlpha = _horizontalLayout ? 0 .0f : 1 .0f ;
256+ self.horizontalZeroButton .contentAlpha = _horizontalLayout ? 1 .0f : 0 .0f ;
259257 };
260258
261259 void (^completionBlock)(BOOL ) = ^(BOOL complete) {
262- self.verticalZeroButton .hidden = toHorizontal ;
263- self.horizontalZeroButton .hidden = !toHorizontal ;
260+ self.verticalZeroButton .hidden = _horizontalLayout ;
261+ self.horizontalZeroButton .hidden = !_horizontalLayout ;
264262 };
265263
266264 // Don't animate if not needed
@@ -394,8 +392,8 @@ - (void)setContentAlpha:(CGFloat)contentAlpha
394392
395393 for (TOPasscodeCircleButton *button in self.keypadButtons ) {
396394 // Skip whichever '0' button is not presently being used
397- if ((self.layout == TOPasscodeKeypadLayoutHorizontal && button == self.verticalZeroButton ) ||
398- (self.layout == TOPasscodeKeypadLayoutVertical && button == self.horizontalZeroButton ))
395+ if ((self.horizontalLayout && button == self.verticalZeroButton ) ||
396+ (! self.horizontalLayout && button == self.horizontalZeroButton ))
399397 {
400398 continue ;
401399 }
0 commit comments