forked from mfazekas/tableviewcellwithbkgnd
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 06a5b14
Showing
17 changed files
with
1,372 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.DS_Store | ||
*.swp | ||
*~.nib | ||
|
||
build/* | ||
|
||
*.pbxuser | ||
*.perspective | ||
*.perspectivev3 | ||
*.mode1v3 | ||
*.mode2v3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// CustomCellBackgroundView.h | ||
// TableTest | ||
// | ||
// Created by Stephan on 22.02.09. | ||
// Copyright 2009 Coriolis Technologies. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
|
||
typedef enum { | ||
CustomCellBackgroundViewPositionTop, | ||
CustomCellBackgroundViewPositionMiddle, | ||
CustomCellBackgroundViewPositionBottom, | ||
CustomCellBackgroundViewPositionSingle | ||
} CustomCellBackgroundViewPosition; | ||
|
||
@interface CustomCellBackgroundView : UIView { | ||
UIColor *borderColor; | ||
UIColor *fillColor; | ||
CustomCellBackgroundViewPosition position; | ||
} | ||
|
||
@property(nonatomic, retain) UIColor *borderColor, *fillColor; | ||
@property(nonatomic) CustomCellBackgroundViewPosition position; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// | ||
// CustomCellBackgroundView.m | ||
// | ||
// Created by Mike Akers on 11/21/08. | ||
// Copyright 2008 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "CustomCellBackgroundView.h" | ||
|
||
static void addRoundedRectToPath(CGContextRef context, CGRect rect, | ||
float ovalWidth,float ovalHeight); | ||
|
||
@implementation CustomCellBackgroundView | ||
@synthesize borderColor, fillColor, position; | ||
|
||
- (BOOL) isOpaque { | ||
return NO; | ||
} | ||
|
||
- (id)initWithFrame:(CGRect)frame { | ||
if (self = [super initWithFrame:frame]) { | ||
// Initialization code | ||
} | ||
return self; | ||
} | ||
|
||
- (void)drawRect:(CGRect)rect { | ||
// Drawing code | ||
CGContextRef c = UIGraphicsGetCurrentContext(); | ||
CGContextSetFillColorWithColor(c, [fillColor CGColor]); | ||
CGContextSetStrokeColorWithColor(c, [borderColor CGColor]); | ||
|
||
if (position == CustomCellBackgroundViewPositionTop) { | ||
CGContextFillRect(c, CGRectMake(0.0f, rect.size.height - 10.0f, rect.size.width, 10.0f)); | ||
CGContextBeginPath(c); | ||
CGContextMoveToPoint(c, 0.0f, rect.size.height - 10.0f); | ||
CGContextAddLineToPoint(c, 0.0f, rect.size.height); | ||
CGContextAddLineToPoint(c, rect.size.width, rect.size.height); | ||
CGContextAddLineToPoint(c, rect.size.width, rect.size.height - 10.0f); | ||
CGContextStrokePath(c); | ||
CGContextClipToRect(c, CGRectMake(0.0f, 0.0f, rect.size.width, rect.size.height - 10.0f)); | ||
} else if (position == CustomCellBackgroundViewPositionBottom) { | ||
CGContextFillRect(c, CGRectMake(0.0f, 0.0f, rect.size.width, 10.0f)); | ||
CGContextBeginPath(c); | ||
CGContextMoveToPoint(c, 0.0f, 10.0f); | ||
CGContextAddLineToPoint(c, 0.0f, 0.0f); | ||
CGContextStrokePath(c); | ||
CGContextBeginPath(c); | ||
CGContextMoveToPoint(c, rect.size.width, 0.0f); | ||
CGContextAddLineToPoint(c, rect.size.width, 10.0f); | ||
CGContextStrokePath(c); | ||
CGContextClipToRect(c, CGRectMake(0.0f, 10.0f, rect.size.width, rect.size.height)); | ||
} else if (position == CustomCellBackgroundViewPositionMiddle) { | ||
CGContextFillRect(c, rect); | ||
CGContextBeginPath(c); | ||
CGContextMoveToPoint(c, 0.0f, 0.0f); | ||
CGContextAddLineToPoint(c, 0.0f, rect.size.height); | ||
CGContextAddLineToPoint(c, rect.size.width, rect.size.height); | ||
CGContextAddLineToPoint(c, rect.size.width, 0.0f); | ||
CGContextStrokePath(c); | ||
return; // no need to bother drawing rounded corners, so we return | ||
} | ||
|
||
// At this point the clip rect is set to only draw the appropriate | ||
// corners, so we fill and stroke a rounded rect taking the entire rect | ||
|
||
CGContextBeginPath(c); | ||
addRoundedRectToPath(c, rect, 10.0f, 10.0f); | ||
CGContextFillPath(c); | ||
|
||
CGContextSetLineWidth(c, 1); | ||
CGContextBeginPath(c); | ||
addRoundedRectToPath(c, rect, 10.0f, 10.0f); | ||
CGContextStrokePath(c); | ||
} | ||
|
||
|
||
- (void)dealloc { | ||
[borderColor release]; | ||
[fillColor release]; | ||
[super dealloc]; | ||
} | ||
|
||
|
||
@end | ||
|
||
static void addRoundedRectToPath(CGContextRef context, CGRect rect, | ||
float ovalWidth,float ovalHeight) | ||
|
||
{ | ||
float fw, fh; | ||
|
||
if (ovalWidth == 0 || ovalHeight == 0) {// 1 | ||
CGContextAddRect(context, rect); | ||
return; | ||
} | ||
|
||
CGContextSaveGState(context);// 2 | ||
|
||
CGContextSetShouldAntialias(context, YES); | ||
CGContextTranslateCTM (context, CGRectGetMinX(rect),// 3 | ||
CGRectGetMinY(rect)); | ||
CGContextScaleCTM (context, ovalWidth, ovalHeight);// 4 | ||
fw = CGRectGetWidth (rect) / ovalWidth;// 5 | ||
fh = CGRectGetHeight (rect) / ovalHeight;// 6 | ||
|
||
CGContextMoveToPoint(context, fw, fh/2); // 7 | ||
CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1);// 8 | ||
CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1);// 9 | ||
CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1);// 10 | ||
CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); // 11 | ||
CGContextClosePath(context);// 12 | ||
|
||
CGContextRestoreGState(context);// 13 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// CustomCellView.h | ||
// TableTest | ||
// | ||
// Created by Stephan on 22.02.09. | ||
// Copyright 2009 Coriolis Technologies. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
|
||
@interface CustomCellView : UITableViewCell { | ||
|
||
IBOutlet UILabel *textLabel; | ||
|
||
} | ||
|
||
@property (nonatomic, retain) UILabel *textLabel; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// CustomCellView.m | ||
// TableTest | ||
// | ||
// Created by Stephan on 22.02.09. | ||
// Copyright 2009 Coriolis Technologies. All rights reserved. | ||
// | ||
|
||
#import "CustomCellView.h" | ||
|
||
|
||
@implementation CustomCellView | ||
|
||
@synthesize textLabel; | ||
|
||
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier | ||
{ | ||
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) { | ||
// Initialization code | ||
} | ||
return self; | ||
} | ||
|
||
|
||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated | ||
{ | ||
[super setSelected:selected animated:animated]; | ||
// Configure the view for the selected state | ||
} | ||
|
||
|
||
- (void)dealloc | ||
{ | ||
[textLabel release]; | ||
[super dealloc]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// TableTestAppDelegate.h | ||
// TableTest | ||
// | ||
// Created by Stephan on 22.02.09. | ||
// Copyright Coriolis Technologies 2009. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class TableTestViewController; | ||
|
||
@interface TableTestAppDelegate : NSObject <UIApplicationDelegate> { | ||
UIWindow *window; | ||
TableTestViewController *viewController; | ||
} | ||
|
||
@property (nonatomic, retain) IBOutlet UIWindow *window; | ||
@property (nonatomic, retain) IBOutlet TableTestViewController *viewController; | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// TableTestAppDelegate.m | ||
// TableTest | ||
// | ||
// Created by Stephan on 22.02.09. | ||
// Copyright Coriolis Technologies 2009. All rights reserved. | ||
// | ||
|
||
#import "TableTestAppDelegate.h" | ||
#import "TableTestViewController.h" | ||
|
||
@implementation TableTestAppDelegate | ||
|
||
@synthesize window; | ||
@synthesize viewController; | ||
|
||
|
||
- (void)applicationDidFinishLaunching:(UIApplication *)application { | ||
|
||
// Override point for customization after app launch | ||
[window addSubview:viewController.view]; | ||
[window makeKeyAndVisible]; | ||
} | ||
|
||
|
||
- (void)dealloc { | ||
[viewController release]; | ||
[window release]; | ||
[super dealloc]; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// TableTestViewController.h | ||
// TableTest | ||
// | ||
// Created by Stephan on 22.02.09. | ||
// Copyright Coriolis Technologies 2009. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface TableTestViewController : UIViewController { | ||
|
||
IBOutlet UITableView *tableView; | ||
NSArray *cellList; | ||
|
||
} | ||
|
||
@property (nonatomic, retain) UITableView *tableView; | ||
@property (nonatomic, retain) NSArray *cellList; | ||
|
||
@end | ||
|
Oops, something went wrong.