From 357849ecc111b2c8a4b6822aa10963679e7e8be6 Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Mon, 20 Aug 2012 17:56:10 +0200 Subject: [PATCH] Improve UACellBackgroundView --- Classes/ContactsTableViewController.m | 3 ++- .../UACellBackgroundView.h | 5 ++--- .../UACellBackgroundView.m | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Classes/ContactsTableViewController.m b/Classes/ContactsTableViewController.m index 32afdc3c7..2dd00fc26 100644 --- a/Classes/ContactsTableViewController.m +++ b/Classes/ContactsTableViewController.m @@ -170,7 +170,8 @@ static void sync_address_book (ABAddressBookRef addressBook, CFDictionaryRef inf UIContactCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId]; if (cell == nil) { cell = [[[UIContactCell alloc] initWithIdentifier:kCellId] autorelease]; - // Background View + + // Background View UACellBackgroundView *selectedBackgroundView = [[[UACellBackgroundView alloc] initWithFrame:CGRectZero] autorelease]; cell.selectedBackgroundView = selectedBackgroundView; [selectedBackgroundView setBackgroundColor:LINPHONE_TABLE_CELL_BACKGROUND_COLOR]; diff --git a/Classes/Utils/UACellBackgroundView/UACellBackgroundView.h b/Classes/Utils/UACellBackgroundView/UACellBackgroundView.h index a2a397792..ad0298870 100644 --- a/Classes/Utils/UACellBackgroundView/UACellBackgroundView.h +++ b/Classes/Utils/UACellBackgroundView/UACellBackgroundView.h @@ -19,12 +19,11 @@ typedef enum { } UACellBackgroundViewPosition; @interface UACellBackgroundView : UIView { - UACellBackgroundViewPosition position; - BOOL automaticPositioning; } @property(nonatomic) UACellBackgroundViewPosition position; -@property(nonatomic, copy) UIColor *backgroundColor; +@property(nonatomic, copy) UIColor *backgroundColor; +@property(nonatomic, copy) UIColor *borderColor; @property(assign) BOOL automaticPositioning; @end diff --git a/Classes/Utils/UACellBackgroundView/UACellBackgroundView.m b/Classes/Utils/UACellBackgroundView/UACellBackgroundView.m index 16e7a144f..f5b043489 100644 --- a/Classes/Utils/UACellBackgroundView/UACellBackgroundView.m +++ b/Classes/Utils/UACellBackgroundView/UACellBackgroundView.m @@ -17,10 +17,14 @@ static void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWi @synthesize position; @synthesize backgroundColor; +@synthesize borderColor; @synthesize automaticPositioning; - (void)initUACellBackgroundView { - [super setBackgroundColor:[UIColor clearColor]]; + backgroundColor = nil; + [self setBackgroundColor:[UIColor colorWithRed:0.02 green:0.549 blue:0.961 alpha:1.0]]; + borderColor = nil; + [self setBorderColor:[UIColor grayColor]]; automaticPositioning = TRUE; } @@ -56,7 +60,16 @@ static void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWi if(backgroundColor != nil) { [backgroundColor release]; } - backgroundColor = [[UIColor alloc]initWithCGColor:abackgroundColor.CGColor]; + backgroundColor = [[UIColor alloc] initWithCGColor:abackgroundColor.CGColor]; + [self setNeedsDisplay]; +} + +- (void)setBorderColor:(UIColor *)aborderColor { + if(borderColor != nil) { + [borderColor release]; + } + + borderColor = [[UIColor alloc] initWithCGColor:aborderColor.CGColor]; [self setNeedsDisplay]; } @@ -123,7 +136,7 @@ static void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWi CGGradientRef myGradient = nil; const CGFloat *default_components = CGColorGetComponents([[self backgroundColor] CGColor]); CGFloat components[8] = {default_components[0], default_components[1], default_components[2], default_components[3], default_components[0] * 0.766f, default_components[1] * 0.766f, default_components[2] * 0.766f, default_components[3]}; - CGContextSetStrokeColorWithColor(c, [[UIColor grayColor] CGColor]); + CGContextSetStrokeColorWithColor(c, [borderColor CGColor]); CGContextSetLineWidth(c, lineWidth); CGContextSetAllowsAntialiasing(c, YES); CGContextSetShouldAntialias(c, YES);