Skip to content

Commit

Permalink
- refs #1 Fix coloring when panning on "Just added" cell
Browse files Browse the repository at this point in the history
  • Loading branch information
jamztang committed Feb 20, 2012
1 parent 2ca7eaf commit bb54cbb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
13 changes: 10 additions & 3 deletions JTGestureBasedTableView/TransformableTableViewCell.m
Expand Up @@ -55,9 +55,16 @@ - (void)layoutSubviews {
[self.textLabel.layer setTransform:transform];
[self.detailTextLabel.layer setTransform:CATransform3DMakeRotation((M_PI / 2) - asinf(fraction), 1, 0, 0)];

self.textLabel.backgroundColor = [self.tintColor colorWithBrightness:0.3 + 0.7*fraction];
self.detailTextLabel.backgroundColor = [self.tintColor colorWithBrightness:0.5 + 0.5*fraction];


if (fraction == 1) {
self.textLabel.backgroundColor = [UIColor clearColor];
self.detailTextLabel.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = self.tintColor;
} else {
self.textLabel.backgroundColor = [self.tintColor colorWithBrightness:0.3 + 0.7*fraction];
self.detailTextLabel.backgroundColor = [self.tintColor colorWithBrightness:0.5 + 0.5*fraction];
self.contentView.backgroundColor = [UIColor clearColor];
}

fraction = 1 / fraction;

Expand Down
14 changes: 9 additions & 5 deletions JTGestureBasedTableViewDemo/ViewController.m
Expand Up @@ -143,19 +143,23 @@ - (void)gestureRecognizer:(JTTableViewGestureRecognizer *)gestureRecognizer need

- (void)gestureRecognizer:(JTTableViewGestureRecognizer *)gestureRecognizer didEnterState:(JTTableViewCellEnterState)state forRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
UIColor *backgroundColor = [[UIColor redColor] colorWithHueOffset:0.12 * indexPath.row / [self tableView:self.tableView numberOfRowsInSection:indexPath.section]];

UIColor *backgroundColor = nil;
switch (state) {
case JTTableViewCellEnterStateMiddle:
cell.contentView.backgroundColor = backgroundColor;
backgroundColor = [[UIColor redColor] colorWithHueOffset:0.12 * indexPath.row / [self tableView:self.tableView numberOfRowsInSection:indexPath.section]];
break;
case JTTableViewCellEnterStateRight:
cell.contentView.backgroundColor = [UIColor greenColor];
backgroundColor = [UIColor greenColor];
break;
default:
cell.contentView.backgroundColor = [UIColor darkGrayColor];
backgroundColor = [UIColor darkGrayColor];
break;
}
cell.contentView.backgroundColor = backgroundColor;
if ([cell isKindOfClass:[TransformableTableViewCell class]]) {
((TransformableTableViewCell *)cell).tintColor = backgroundColor;
}
}

// This is needed to be implemented to let our delegate choose whether the panning gesture should work
Expand Down

0 comments on commit bb54cbb

Please sign in to comment.