Skip to content

Commit

Permalink
Add doc
Browse files Browse the repository at this point in the history
Implement custom button height feature request #71
  • Loading branch information
dogo committed Mar 10, 2015
1 parent 0793fa9 commit 2820f6f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
12 changes: 6 additions & 6 deletions SCLAlertView/SCLAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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];

Expand Down
12 changes: 9 additions & 3 deletions SCLAlertView/SCLButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.
Expand Down
20 changes: 14 additions & 6 deletions SCLAlertView/SCLButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,38 @@ @implementation SCLButton
- (id)init
{
self = [super init];
if (self) {
// Do something
if (self)
{
[self setup];
}
return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if(self) {
// Do something
if(self)
{
[self setup];
}
return self;
}

- (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;
Expand Down

0 comments on commit 2820f6f

Please sign in to comment.