diff --git a/src/TapkuLibrary/TKAlertCenter.h b/src/TapkuLibrary/TKAlertCenter.h index b195cf0e..a4052e08 100644 --- a/src/TapkuLibrary/TKAlertCenter.h +++ b/src/TapkuLibrary/TKAlertCenter.h @@ -42,6 +42,10 @@ CGRect _alertFrame; } +@property (strong) UIColor *alertBackgroundColor; +@property (strong) UIFont *alertFont; +@property (strong) UIColor *alertTextColor; + /** Returns the process’s default notification center. @return The current process’s default notification center, which is used for alert notifications. */ diff --git a/src/TapkuLibrary/TKAlertCenter.m b/src/TapkuLibrary/TKAlertCenter.m index 96382982..1d2d87cb 100644 --- a/src/TapkuLibrary/TKAlertCenter.m +++ b/src/TapkuLibrary/TKAlertCenter.m @@ -31,7 +31,18 @@ #import "TKAlertCenter.h" #import "UIView+TKCategory.h" + +#ifndef kTKAlertViewBackgroundColor +#define kTKAlertViewBackgroundColor [UIColor colorWithWhite:0 alpha:0.8] +#endif +#ifndef kTKAlertViewFont +#define kTKAlertViewFont [UIFont boldSystemFontOfSize:14] +#endif + +#ifndef kTKAlertViewTextColor +#define kTKAlertViewTextColor [UIColor whiteColor] +#endif #pragma mark - @interface TKAlertView : UIView { @@ -40,6 +51,10 @@ @interface TKAlertView : UIView { UIImage *_image; } +@property (strong) UIColor *alertBackgroundColor; +@property (strong) UIFont *alertFont; +@property (strong) UIColor *alertTextColor; + - (id) init; - (void) setMessageText:(NSString*)str; - (void) setImage:(UIImage*)image; @@ -54,6 +69,9 @@ - (id) init{ if(!(self = [super initWithFrame:CGRectMake(0, 0, 100, 100)])) return nil; _messageRect = CGRectInset(self.bounds, 10, 10); self.backgroundColor = [UIColor clearColor]; + self.alertBackgroundColor = kTKAlertViewBackgroundColor; + self.alertFont = kTKAlertViewFont; + self.alertTextColor = kTKAlertViewTextColor; return self; } @@ -81,11 +99,11 @@ - (void) _drawRoundRectangleInRect:(CGRect)rect withRadius:(CGFloat)radius{ - (void) drawRect:(CGRect)rect{ - [[UIColor colorWithWhite:0 alpha:0.8] set]; + [self.alertBackgroundColor set]; [self _drawRoundRectangleInRect:rect withRadius:10]; - [[UIColor whiteColor] set]; + [self.alertTextColor set]; [_text drawInRect:_messageRect - withFont:[UIFont boldSystemFontOfSize:14] + withFont:self.alertFont lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentCenter]; @@ -100,7 +118,7 @@ - (void) drawRect:(CGRect)rect{ #pragma mark Setter Methods - (void) adjust{ - CGSize s = [_text sizeWithFont:[UIFont boldSystemFontOfSize:14] + CGSize s = [_text sizeWithFont:self.alertFont constrainedToSize:CGSizeMake(160,200) lineBreakMode:NSLineBreakByWordWrapping]; @@ -161,6 +179,35 @@ - (id) init{ return self; } +-(void)setAlertFont:(UIFont *)alertFont +{ + _alertView.alertFont = alertFont; +} + +- (UIFont *)alertFont +{ + return _alertView.alertFont; +} + +-(void)setAlertBackgroundColor:(UIColor *)alertBackgroundColor +{ + _alertView.alertBackgroundColor = alertBackgroundColor; +} + +- (UIColor *)alertBackgroundColor +{ + return _alertView.alertBackgroundColor; +} + +-(void)setAlertTextColor:(UIColor *)alertTextColor +{ + _alertView.alertTextColor = alertTextColor; +} + +- (UIColor *)alertTextColor +{ + return _alertView.alertTextColor; +} #pragma mark Show Alert Message - (void) showAlerts{