3

I'm working on a custom "Pulse style" UITableView according to this tutorial, and everything is going great. I've made some modifications and extensions but there is one feature I'd like to implement that I need some help with: the color of the horizontal bounce regions.

This is the method that creates my cell with a table view in it:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    
    NSString *cellIdentifier = [@"TableViewCell" stringByAppendingFormat:@"%i", self.content.indexInArrayOfViews];
    UIView *view = [self.content viewAtIndex:indexPath.row];
    UITableViewCell *cell = [self.horizontalTableView dequeueReusableCellWithIdentifier:cellIdentifier];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier] autorelease];

        view.center = CGPointMake(view.center.y,view.center.x);
        view.contentMode = UIViewContentModeCenter;

        view.transform = CGAffineTransformMakeRotation(M_PI_2);
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }

    [cell addSubview:view];

    return cell;
}

I'm aware there is a reuse cell issue, but for right now I want to change this color here [IMG].

I can control the color of the vertical table view bounce areas, but I am having difficulty replicating this success for my horizontal view.

This is how I do it vertically:

CGRect frame = self.tableView.bounds;
    frame.origin.y = -frame.size.height;
    UIView* topBack = [[UIView alloc] initWithFrame:frame];
    topBack.backgroundColor = [self.delegate backgroundColorForTopOfTableView];
    [self.tableView addSubview:topBack];
    [topBack release];

This was according to this StackOverflow question.

How do I change the color/background of my horizontal table view (which is nested in a table view cell)?

Here is an album with some relevant iPhone screenshots and IB screenshots.

Community
  • 1
  • 1
PLJNS
  • 451
  • 4
  • 14

1 Answers1

0

I discovered a solution:

if (indexPath.row == 0){
    UIView *bounce = [[UIView alloc] initWithFrame:CGRectMake(-320, 0, 320, 150)];
    bounce.backgroundColor = [self.delegate colorForBounceRegionAtRow:self.content.indexInArrayOfViews];
    [view addSubview:bounce];
}

if (indexPath.row + 1 == self.content.viewCount){
    UIView *bounce = [[UIView alloc] initWithFrame:CGRectMake([self.content widthOfViewAtIndex:self.content.viewCount - 1], 0, 320*2, [self.content greatestHeight])];
    bounce.backgroundColor = [self.delegate colorForBounceRegionAtRow:self.content.indexInArrayOfViews];
    [view addSubview:bounce];
}

This adds a full screen's worth of colored rectangle to the first and last elements, giving the illusion of a bounce region.

PLJNS
  • 451
  • 4
  • 14