Skip to content

Commit

Permalink
Merge pull request #70 from wzs/master
Browse files Browse the repository at this point in the history
Minor icon and button customization fixes
  • Loading branch information
dogo committed Feb 18, 2015
2 parents 60a57d7 + de63437 commit f4d7917
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
17 changes: 15 additions & 2 deletions SCLAlertView/SCLAlertView.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,20 @@ typedef NS_ENUM(NSInteger, SCLAlertViewBackground)
*/
@property (nonatomic, copy) SCLAttributedFormatBlock attributedFormatBlock;

/** Set button format block.
/** Set Complete button format block.
*
* Holds the button format block.
* Support keys : backgroundColor, textColor
* Support keys : backgroundColor, borderColor, textColor
*/
@property (nonatomic, copy) CompleteButtonFormatBlock completeButtonFormatBlock;

/** Set button format block.
*
* Holds the button format block.
* Support keys : backgroundColor, borderColor, textColor
*/
@property (nonatomic, copy) ButtonFormatBlock buttonFormatBlock;

/** Hide animation type
*
* Holds the hide animation type.
Expand Down Expand Up @@ -149,6 +156,12 @@ typedef NS_ENUM(NSInteger, SCLAlertViewBackground)
*/
@property (nonatomic, strong) UIColor *backgroundViewColor;

/** Set custom tint color for icon image.
*
* SCLAlertView icon tint color
*/
@property (nonatomic, strong) UIColor *iconTintColor;

/** Warns that alerts is gone
*
* Warns that alerts is gone using block
Expand Down
26 changes: 17 additions & 9 deletions SCLAlertView/SCLAlertView.m
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,12 @@ - (SCLButton *)addDoneButtonWithTitle:(NSString *)title
- (SCLButton *)addButton:(NSString *)title actionBlock:(SCLActionBlock)action
{
SCLButton *btn = [self addButton:title];

if (_buttonFormatBlock != nil)
{
btn.buttonFormatBlock = _buttonFormatBlock;
}

btn.actionType = Block;
btn.actionBlock = action;
[btn addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
Expand Down Expand Up @@ -760,7 +766,11 @@ -(SCLAlertViewResponder *)showTitle:(UIViewController *)vc image:(UIImage *)imag
}
else
{
self.circleIconImageView.image = iconImage;
if (self.iconTintColor) {
self.circleIconImageView.tintColor = self.iconTintColor;
iconImage = [iconImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
self.circleIconImageView.image = iconImage;
}

for (UITextField *textField in _inputs)
Expand All @@ -770,6 +780,12 @@ -(SCLAlertViewResponder *)showTitle:(UIViewController *)vc image:(UIImage *)imag

for (SCLButton *btn in _buttons)
{
if (style == Warning)
{
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
}
btn.defaultBackgroundColor = viewColor;

if (btn.completeButtonFormatBlock != nil)
{
[btn parseConfig:btn.completeButtonFormatBlock()];
Expand All @@ -778,14 +794,6 @@ -(SCLAlertViewResponder *)showTitle:(UIViewController *)vc image:(UIImage *)imag
{
[btn parseConfig:btn.buttonFormatBlock()];
}
else
{
btn.defaultBackgroundColor = viewColor;
}
if (style == Warning)
{
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
}
}

// Adding duration
Expand Down

0 comments on commit f4d7917

Please sign in to comment.