From 1ca14a623d08b94571211876e89ffe4e193fd663 Mon Sep 17 00:00:00 2001 From: Nik Reiman Date: Mon, 30 May 2011 16:49:58 +0200 Subject: [PATCH] Added a bit more flexibility in skinning Can now pass in arrow image, text color, shadow color, and background color. Also added static methods to get the defaults used in the component. --- .../Classes/View/EGORefreshTableHeaderView.h | 11 ++++- .../Classes/View/EGORefreshTableHeaderView.m | 42 +++++++++++++++---- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h index 0ec72f0..5a0a370 100755 --- a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h +++ b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.h @@ -49,7 +49,16 @@ typedef enum{ @property(nonatomic,assign) id delegate; -- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor; ++ (NSString *)defaultArrowImageName; ++ (UIColor *)defaultTextColor; ++ (UIColor *)defaultShadowColor; ++ (UIColor *)defaultBackgroundColor; + +- (id)initWithFrame:(CGRect)frame + arrowImageName:(NSString *)arrow + textColor:(UIColor *)textColor + shadowColor:(UIColor *)shadowColor + backgroundColor:(UIColor *)backgroundColor; - (void)refreshLastUpdatedDate; - (void)egoRefreshScrollViewDidScroll:(UIScrollView *)scrollView; diff --git a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m index 87f1786..816c09d 100755 --- a/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m +++ b/EGOTableViewPullRefresh/Classes/View/EGORefreshTableHeaderView.m @@ -27,7 +27,6 @@ #import "EGORefreshTableHeaderView.h" -#define TEXT_COLOR [UIColor colorWithRed:87.0/255.0 green:108.0/255.0 blue:137.0/255.0 alpha:1.0] #define FLIP_ANIMATION_DURATION 0.18f @@ -39,18 +38,23 @@ @implementation EGORefreshTableHeaderView @synthesize delegate=_delegate; - -- (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UIColor *)textColor { +- (id)initWithFrame:(CGRect)frame + arrowImageName:(NSString *)arrow + textColor:(UIColor *)textColor + shadowColor:(UIColor *)shadowColor + backgroundColor:(UIColor *)backgroundColor { if (self = [super initWithFrame:frame]) { self.autoresizingMask = UIViewAutoresizingFlexibleWidth; - self.backgroundColor = [UIColor colorWithRed:226.0/255.0 green:231.0/255.0 blue:237.0/255.0 alpha:1.0]; + self.backgroundColor = backgroundColor; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, frame.size.height - 30.0f, self.frame.size.width, 20.0f)]; label.autoresizingMask = UIViewAutoresizingFlexibleWidth; label.font = [UIFont systemFontOfSize:12.0f]; label.textColor = textColor; - label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; + if(shadowColor != nil) { + label.shadowColor = shadowColor; + } label.shadowOffset = CGSizeMake(0.0f, 1.0f); label.backgroundColor = [UIColor clearColor]; label.textAlignment = UITextAlignmentCenter; @@ -62,7 +66,9 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI label.autoresizingMask = UIViewAutoresizingFlexibleWidth; label.font = [UIFont boldSystemFontOfSize:13.0f]; label.textColor = textColor; - label.shadowColor = [UIColor colorWithWhite:0.9f alpha:1.0f]; + if(shadowColor != nil) { + label.shadowColor = shadowColor; + } label.shadowOffset = CGSizeMake(0.0f, 1.0f); label.backgroundColor = [UIColor clearColor]; label.textAlignment = UITextAlignmentCenter; @@ -100,7 +106,29 @@ - (id)initWithFrame:(CGRect)frame arrowImageName:(NSString *)arrow textColor:(UI } - (id)initWithFrame:(CGRect)frame { - return [self initWithFrame:frame arrowImageName:@"blueArrow.png" textColor:TEXT_COLOR]; + return [self initWithFrame:frame + arrowImageName:[EGORefreshTableHeaderView defaultArrowImageName] + textColor:[EGORefreshTableHeaderView defaultTextColor] + shadowColor:[EGORefreshTableHeaderView defaultShadowColor] + backgroundColor:[EGORefreshTableHeaderView defaultBackgroundColor]]; +} + +#pragma mark - Getters + ++ (NSString *)defaultArrowImageName { + return @"blueArrow.png"; +} + ++ (UIColor *)defaultTextColor { + return [UIColor colorWithRed:87.0/255.0 green:108.0/255.0 blue:137.0/255.0 alpha:1.0]; +} + ++ (UIColor *)defaultShadowColor { + return [UIColor colorWithWhite:0.9f alpha:1.0f]; +} + ++ (UIColor *)defaultBackgroundColor { + return [UIColor colorWithRed:87.0/255.0 green:108.0/255.0 blue:137.0/255.0 alpha:1.0]; } #pragma mark -