From 2820f6fc1d10ccdbd61abc7b8a64d6d8e1f0c219 Mon Sep 17 00:00:00 2001 From: Diogo Autilio Date: Tue, 10 Mar 2015 20:09:56 -0300 Subject: [PATCH] Add doc Implement custom button height feature request #71 --- SCLAlertView/SCLAlertView.m | 12 ++++++------ SCLAlertView/SCLButton.h | 12 +++++++++--- SCLAlertView/SCLButton.m | 20 ++++++++++++++------ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/SCLAlertView/SCLAlertView.m b/SCLAlertView/SCLAlertView.m index c4ee348..3f3d50e 100755 --- a/SCLAlertView/SCLAlertView.m +++ b/SCLAlertView/SCLAlertView.m @@ -245,9 +245,12 @@ - (void)viewWillLayoutSubviews // Buttons for (SCLButton *btn in _buttons) { - btn.frame = CGRectMake(12.0f, y, _windowWidth - 24.0f, 35.0f); + btn.frame = CGRectMake(12.0f, y, _windowWidth - 24.0f, btn.buttonSize.height); btn.layer.cornerRadius = 3.0f; - y += 45.0f; + y += btn.buttonSize.height + 10.0f; + + // Update view height + self.windowHeight += btn.buttonSize.height + 10.0f; } } @@ -487,15 +490,12 @@ -(void)keyboardWillHide:(NSNotification *)notification - (SCLButton *)addButton:(NSString *)title { - // Update view height - self.windowHeight += 45.0f; - // Add button SCLButton *btn = [[SCLButton alloc] init]; btn.layer.masksToBounds = YES; [btn setTitle:title forState:UIControlStateNormal]; btn.titleLabel.font = [UIFont fontWithName:_buttonsFontFamily size:_buttonsFontSize]; - + [_contentView addSubview:btn]; [_buttons addObject:btn]; diff --git a/SCLAlertView/SCLButton.h b/SCLAlertView/SCLButton.h index 1b08288..76dc0c9 100644 --- a/SCLAlertView/SCLButton.h +++ b/SCLAlertView/SCLButton.h @@ -29,15 +29,15 @@ typedef NS_ENUM(NSInteger, SCLActionType) */ @property SCLActionType actionType; -/** TODO +/** Set action button block. * * TODO */ @property (nonatomic, copy) SCLActionBlock actionBlock; -/** TODO +/** Set Validation button block. * - * TODO + * Set one kind of validation and keeps the alert visible until the validation is successful */ @property (nonatomic, copy) SCLValidationBlock validationBlock; @@ -61,6 +61,12 @@ typedef NS_ENUM(NSInteger, SCLActionType) */ @property (nonatomic, strong) UIColor *defaultBackgroundColor; +/** Set SCLButton size. + * + * Set SCLButton size. + */ +@property (nonatomic) CGSize buttonSize; + /** Set Target object. * * Target is an object that holds the information necessary to send a message to another object when an event occurs. diff --git a/SCLAlertView/SCLButton.m b/SCLAlertView/SCLButton.m index 3bcc819..c2b1b99 100644 --- a/SCLAlertView/SCLButton.m +++ b/SCLAlertView/SCLButton.m @@ -13,8 +13,9 @@ @implementation SCLButton - (id)init { self = [super init]; - if (self) { - // Do something + if (self) + { + [self setup]; } return self; } @@ -22,8 +23,9 @@ - (id)init - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; - if(self) { - // Do something + if(self) + { + [self setup]; } return self; } @@ -31,12 +33,18 @@ - (id)initWithCoder:(NSCoder *)aDecoder - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; - if (self) { - // Do something + if (self) + { + [self setup]; } return self; } +- (void)setup +{ + self.buttonSize = CGSizeMake(240.0f, 35.0f); +} + - (void)setHighlighted:(BOOL)highlighted { self.backgroundColor = (highlighted) ? [self darkerColorForColor:_defaultBackgroundColor] : _defaultBackgroundColor;