diff --git a/README.md b/README.md index dd967fe..3435c9a 100644 --- a/README.md +++ b/README.md @@ -29,18 +29,6 @@ SCLAlertView *alert = [[SCLAlertView alloc] init]; [alert showCustom:self image:[UIImage imageNamed:@"git"] color:color title:@"Custom" subTitle:@"Add a custom icon and color for your own type of alert!" closeButtonTitle:@"OK" duration:0.0f]; // Custom ``` -###Advanced -```Objective-C -SCLAlertView *alert = [[SCLAlertView alloc] init]; - -[alert showTitle:self // Parent view controller - title:@"Congratulations" // Title of view - subTitle:@"Operation successfully completed." // String of view - style:Success // Styles - see below. - completeText:@"Done" // Optional button value - duration:2.0f]; // Duration to show before closing automatically -``` - ###Add buttons ```Objective-C SCLAlertView *alert = [[SCLAlertView alloc] init]; @@ -122,6 +110,12 @@ alert.showAnimationType = SlideInFromLeft; //Set background type (Default is Shadow) alert.backgroundType = Blur; +//Overwrite SCLAlertView (Buttons, top circle and borders) colors +alert.customViewColor = [UIColor purpleColor]; + +//Overwrite SCLAlertView background color +alert.backgroundViewColor = [UIColor cyanColor]; + //Using sound alert.soundURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/right_answer.mp3", [[NSBundle mainBundle] resourcePath]]]; ``` diff --git a/SCLAlertView-Objective-C.podspec b/SCLAlertView-Objective-C.podspec index 5f5081f..4e198e3 100644 --- a/SCLAlertView-Objective-C.podspec +++ b/SCLAlertView-Objective-C.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "SCLAlertView-Objective-C" - spec.version = "0.5.2" + spec.version = "0.5.3" spec.summary = "Beautiful animated Alert View. Written in Swift but ported to Objective-C" spec.homepage = "https://github.com/dogo/SCLAlertView" spec.screenshots = "https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot.png", "https://raw.githubusercontent.com/dogo/SCLAlertView/master/ScreenShots/ScreenShot2.png" diff --git a/SCLAlertView/SCLAlertView.h b/SCLAlertView/SCLAlertView.h index 6898462..c7e00f4 100755 --- a/SCLAlertView/SCLAlertView.h +++ b/SCLAlertView/SCLAlertView.h @@ -136,6 +136,19 @@ typedef NS_ENUM(NSInteger, SCLAlertViewBackground) */ @property (nonatomic) SCLAlertViewBackground backgroundType; +/** Set custom color to SCLAlertView. + * + * SCLAlertView custom color. + * (Buttons, top circle and borders) + */ +@property (nonatomic, strong) UIColor *customViewColor; + +/** Set custom color to SCLAlertView background. + * + * SCLAlertView background custom color. + */ +@property (nonatomic, strong) UIColor *backgroundViewColor; + /** Warns that alerts is gone * * Warns that alerts is gone using block diff --git a/SCLAlertView/SCLAlertView.m b/SCLAlertView/SCLAlertView.m index 49f07b4..22e7375 100755 --- a/SCLAlertView/SCLAlertView.m +++ b/SCLAlertView/SCLAlertView.m @@ -134,9 +134,6 @@ - (instancetype)init _contentView.layer.masksToBounds = YES; _contentView.layer.borderWidth = 0.5f; - // Circle View Background - _circleViewBackground.backgroundColor = [UIColor whiteColor]; - // Background View _backgroundView.userInteractionEnabled = YES; @@ -160,10 +157,10 @@ - (instancetype)init } // Colors - _contentView.backgroundColor = [UIColor whiteColor]; - _labelTitle.textColor = UIColorFromRGB(0x4D4D4D); - _viewText.textColor = UIColorFromRGB(0x4D4D4D); - _contentView.layer.borderColor = UIColorFromRGB(0xCCCCCC).CGColor; + self.backgroundViewColor = [UIColor whiteColor]; + _labelTitle.textColor = UIColorFromRGB(0x4D4D4D); //Dark Grey + _viewText.textColor = UIColorFromRGB(0x4D4D4D); //Dark Grey + _contentView.layer.borderColor = UIColorFromRGB(0xCCCCCC).CGColor; //Light Grey } return self; } @@ -320,6 +317,16 @@ - (void)setButtonsTextFontFamily:(NSString *)buttonsFontFamily withSize:(CGFloat self.buttonsFontSize = size; } +#pragma mark - Background Color + +- (void)setBackgroundViewColor:(UIColor *)backgroundViewColor +{ + _backgroundViewColor = backgroundViewColor; + _circleViewBackground.backgroundColor = _backgroundViewColor; + _contentView.backgroundColor = _backgroundViewColor; + _viewText.backgroundColor = _backgroundViewColor; +} + #pragma mark - Sound - (void)setSoundURL:(NSURL *)soundURL @@ -571,6 +578,12 @@ -(SCLAlertViewResponder *)showTitle:(UIViewController *)vc image:(UIImage *)imag self.circleIconHeight *= 2.0f; break; } + + // Custom Alert color + if(_customViewColor) + { + viewColor = _customViewColor; + } // Title if([title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length > 0) diff --git a/SCLAlertView/SCLButton.h b/SCLAlertView/SCLButton.h index 798df5f..be3c8ad 100644 --- a/SCLAlertView/SCLButton.h +++ b/SCLAlertView/SCLButton.h @@ -55,9 +55,9 @@ typedef NS_ENUM(NSInteger, SCLActionType) */ @property (nonatomic, copy) ButtonFormatBlock buttonFormatBlock; -/** TODO +/** Set SCLButton color. * - * TODO + * Set SCLButton color. */ @property (nonatomic, strong) UIColor *defaultBackgroundColor; diff --git a/SCLAlertViewExample/ViewController.m b/SCLAlertViewExample/ViewController.m index 95ebea0..1ea5056 100644 --- a/SCLAlertViewExample/ViewController.m +++ b/SCLAlertViewExample/ViewController.m @@ -117,6 +117,8 @@ - (IBAction)showAdvanced:(id)sender { SCLAlertView *alert = [[SCLAlertView alloc] init]; + alert.backgroundViewColor = [UIColor cyanColor]; + [alert setTitleFontFamily:@"Superclarendon" withSize:20.0f]; [alert setBodyTextFontFamily:@"TrebuchetMS" withSize:14.0f]; [alert setButtonsTextFontFamily:@"Baskerville" withSize:14.0f]; @@ -151,7 +153,7 @@ - (IBAction)showAdvanced:(id)sender [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:redRange]; NSRange greenRange = [value rangeOfString:@"successfully" options:NSCaseInsensitiveSearch]; - [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:greenRange]; + [subTitle addAttribute:NSForegroundColorAttributeName value:[UIColor brownColor] range:greenRange]; NSRange underline = [value rangeOfString:@"completed" options:NSCaseInsensitiveSearch]; [subTitle addAttributes:@{NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle)} range:underline];