123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #import "TOPasscodeSettingsKeypadButton.h"
- #import "TOPasscodeButtonLabel.h"
- @interface TOPasscodeSettingsKeypadButton ()
- @property (nonatomic, strong, readwrite) TOPasscodeButtonLabel *buttonLabel;
- @end
- @implementation TOPasscodeSettingsKeypadButton
- + (TOPasscodeSettingsKeypadButton *)button
- {
- TOPasscodeSettingsKeypadButton *button = [TOPasscodeSettingsKeypadButton buttonWithType:UIButtonTypeCustom];
- button.frame = CGRectMake(0,0,100,60);
- return button;
- }
- #pragma mark - Lazy Accessor -
- - (TOPasscodeButtonLabel *)buttonLabel
- {
- if (_buttonLabel) { return _buttonLabel; }
- CGRect frame = self.bounds;
- frame.size.height -= self.bottomInset;
- _buttonLabel = [[TOPasscodeButtonLabel alloc] initWithFrame:frame];
- _buttonLabel.userInteractionEnabled = NO;
- _buttonLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- [self addSubview:_buttonLabel];
- return _buttonLabel;
- }
- #pragma mark - Layout Accessor -
- - (void)setBottomInset:(CGFloat)bottomInset
- {
- _bottomInset = bottomInset;
- CGRect frame = self.bounds;
- frame.size.height -= _bottomInset;
- self.buttonLabel.frame = frame;
- [self setNeedsLayout];
- }
- #pragma mark - Control Accessor -
- - (void)setEnabled:(BOOL)enabled
- {
- [super setEnabled:enabled];
- self.buttonLabel.alpha = enabled ? 1.0f : 0.5f;
- }
- #pragma mark - Background Image Accessor -
- - (void)setHighlighted:(BOOL)highlighted {
- [self.layer removeAllAnimations];
- [UIView transitionWithView:self
- duration:0.25
- options:UIViewAnimationOptionTransitionCrossDissolve |
- UIViewAnimationOptionAllowAnimatedContent |
- UIViewAnimationOptionAllowUserInteraction
- animations:^{
- [super setHighlighted:highlighted];
- } completion:nil];
- }
- - (void)setButtonBackgroundImage:(UIImage *)buttonBackgroundImage
- {
- [self setBackgroundImage:buttonBackgroundImage forState:UIControlStateNormal];
- }
- - (UIImage *)buttonBackgroundImage { return [self backgroundImageForState:UIControlStateNormal]; }
- - (void)setButtonTappedBackgroundImage:(UIImage *)buttonTappedBackgroundImage
- {
- [self setBackgroundImage:buttonTappedBackgroundImage forState:UIControlStateHighlighted];
- }
- - (UIImage *)buttonTappedBackgroundImage { return [self backgroundImageForState:UIControlStateHighlighted]; }
- @end
|