小编Shi*_*hao的帖子

uitableview第一个和最后一个可见的单元格颜色变化

我正试图在UITableViewiPhone中实现这个功能:总是只有FIRST和LAST VISIBLE单元格有不同的背景颜色,比如红色,而其他单元格的颜色保持白色.滚动期间的平滑变化.
我试过了:

.m文件中:

NSIndexPath *firstRow;
UITableViewCell* firstCell;

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @"tableCell";    
    tableCell *cell = (tableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    if (cell == nil) 
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"tableCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    } 

    cell.nameLabel.text = [tableData objectAtIndex:indexPath.row];
    //cell.thumbnailImageView.image = image;

    return cell;
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;
{
    NSArray *visible = [tableView indexPathsForVisibleRows];
    firstRow = (NSIndexPath *)[visible objectAtIndex:0];
    firstCell = [tableView cellForRowAtIndexPath:firstRow]; …
Run Code Online (Sandbox Code Playgroud)

uitableview ios

1
推荐指数
1
解决办法
4563
查看次数

标签 统计

ios ×1

uitableview ×1