Skip to content

Commit e9be3b0

Browse files
author
Diogo Autilio
committed
Custom background color
1 parent 75d774a commit e9be3b0

3 files changed

Lines changed: 24 additions & 8 deletions

File tree

SCLAlertView/SCLAlertView.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,16 @@ typedef NS_ENUM(NSInteger, SCLAlertViewBackground)
139139
/** Set custom color to SCLAlertView.
140140
*
141141
* SCLAlertView custom color.
142+
* (Buttons, circle and text field borders)
142143
*/
143144
@property (nonatomic, strong) UIColor *customViewColor;
144145

146+
/** Set custom color to SCLAlertView background.
147+
*
148+
* SCLAlertView background custom color.
149+
*/
150+
@property (nonatomic, strong) UIColor *backgroundViewColor;
151+
145152
/** Warns that alerts is gone
146153
*
147154
* Warns that alerts is gone using block

SCLAlertView/SCLAlertView.m

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,6 @@ - (instancetype)init
134134
_contentView.layer.masksToBounds = YES;
135135
_contentView.layer.borderWidth = 0.5f;
136136

137-
// Circle View Background
138-
_circleViewBackground.backgroundColor = [UIColor whiteColor];
139-
140137
// Background View
141138
_backgroundView.userInteractionEnabled = YES;
142139

@@ -160,10 +157,10 @@ - (instancetype)init
160157
}
161158

162159
// Colors
163-
_contentView.backgroundColor = [UIColor whiteColor];
164-
_labelTitle.textColor = UIColorFromRGB(0x4D4D4D);
165-
_viewText.textColor = UIColorFromRGB(0x4D4D4D);
166-
_contentView.layer.borderColor = UIColorFromRGB(0xCCCCCC).CGColor;
160+
self.backgroundViewColor = [UIColor whiteColor];
161+
_labelTitle.textColor = UIColorFromRGB(0x4D4D4D); //Dark Grey
162+
_viewText.textColor = UIColorFromRGB(0x4D4D4D); //Dark Grey
163+
_contentView.layer.borderColor = UIColorFromRGB(0xCCCCCC).CGColor; //Light Grey
167164
}
168165
return self;
169166
}
@@ -320,6 +317,16 @@ - (void)setButtonsTextFontFamily:(NSString *)buttonsFontFamily withSize:(CGFloat
320317
self.buttonsFontSize = size;
321318
}
322319

320+
#pragma mark - Background Color
321+
322+
- (void)setBackgroundViewColor:(UIColor *)backgroundViewColor
323+
{
324+
_backgroundViewColor = backgroundViewColor;
325+
_circleViewBackground.backgroundColor = _backgroundViewColor;
326+
_contentView.backgroundColor = _backgroundViewColor;
327+
_viewText.backgroundColor = _backgroundViewColor;
328+
}
329+
323330
#pragma mark - Sound
324331

325332
- (void)setSoundURL:(NSURL *)soundURL

SCLAlertViewExample/ViewController.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ - (IBAction)showAdvanced:(id)sender
117117
{
118118
SCLAlertView *alert = [[SCLAlertView alloc] init];
119119

120+
alert.backgroundViewColor = [UIColor cyanColor];
121+
120122
[alert setTitleFontFamily:@"Superclarendon" withSize:20.0f];
121123
[alert setBodyTextFontFamily:@"TrebuchetMS" withSize:14.0f];
122124
[alert setButtonsTextFontFamily:@"Baskerville" withSize:14.0f];
@@ -151,7 +153,7 @@ - (IBAction)showAdvanced:(id)sender
151153
[subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange];
152154

153155
NSRange greenRange = [value rangeOfString:@"successfully" options:NSCaseInsensitiveSearch];
154-
[subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:greenRange];
156+
[subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor brownColor] range:greenRange];
155157

156158
NSRange underline = [value rangeOfString:@"completed" options:NSCaseInsensitiveSearch];
157159
[subTitle addAttributes:@{NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle)} range:underline];

0 commit comments

Comments
 (0)