Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ALAlertBanner/ALAlertBannerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ typedef enum {
-(void)updateSizeAndSubviewsAnimated:(BOOL)animated;
-(void)updatePositionAfterRotationWithY:(CGFloat)yPos animated:(BOOL)animated;

#pragma mark - Configurable colors:

+(void)setColor:(UIColor *)color forBannerStyle:(ALAlertBannerStyle)style;
+(UIColor *)colorFrBannerStyle:(ALAlertBannerStyle)style;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

colorForBannerStyle perhaps?

@end
51 changes: 36 additions & 15 deletions ALAlertBanner/ALAlertBannerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -633,21 +633,8 @@ -(void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();

UIColor *fillColor;
switch (self.style) {
case ALAlertBannerStyleSuccess:
fillColor = [UIColor colorWithRed:(77/255.0) green:(175/255.0) blue:(67/255.0) alpha:1.f];
break;
case ALAlertBannerStyleFailure:
fillColor = [UIColor colorWithRed:(173/255.0) green:(48/255.0) blue:(48/255.0) alpha:1.f];
break;
case ALAlertBannerStyleNotify:
fillColor = [UIColor colorWithRed:(48/255.0) green:(110/255.0) blue:(173/255.0) alpha:1.f];
break;
case ALAlertBannerStyleAlert:
fillColor = [UIColor colorWithRed:(211/255.0) green:(209/255.0) blue:(100/255.0) alpha:1.f];
break;
}
UIColor *fillColor = [ALAlertBannerView colorFrBannerStyle:self.style];


NSArray *colorsArray = [NSArray arrayWithObjects:(id)[fillColor CGColor], (id)[[fillColor darkerColor] CGColor], nil];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
Expand All @@ -665,4 +652,38 @@ -(void)drawRect:(CGRect)rect
CGContextFillRect(context, CGRectMake(0, 0, rect.size.width, 1.f));
}


#pragma mark - Configurable colors:

+(NSMutableDictionary *)colors{

static dispatch_once_t pred;
static NSMutableDictionary *shared = nil;

dispatch_once(&pred, ^{
shared = [[NSMutableDictionary alloc] initWithDictionary:
@{
@(ALAlertBannerStyleSuccess) : [UIColor colorWithRed:(77/255.0) green:(175/255.0) blue:(67/255.0) alpha:1.f],
@(ALAlertBannerStyleFailure) : [UIColor colorWithRed:(173/255.0) green:(48/255.0) blue:(48/255.0) alpha:1.f],
@(ALAlertBannerStyleNotify) : [UIColor colorWithRed:(48/255.0) green:(110/255.0) blue:(173/255.0) alpha:1.f],
@(ALAlertBannerStyleAlert) : [UIColor colorWithRed:(211/255.0) green:(209/255.0) blue:(100/255.0) alpha:1.f],
}];

//[shared printEntityList];
});
return shared;
}
+(void)setColor:(UIColor *)color forBannerStyle:(ALAlertBannerStyle)style{

[[ALAlertBannerView colors] setObject:color forKey:@(style)];

}
+(UIColor *)colorFrBannerStyle:(ALAlertBannerStyle)style{


UIColor *fillColor = [[ALAlertBannerView colors] objectForKey:@(style)];
return fillColor;
}


@end